Map Interface, HashMap Class
- (J2SE) What is the difference between a HashMap and Map?
Answer:
A Map is an Interface and a Hashmap is class that implements that interface.
- What are 2 facts with respect to arrays?
Answer:
- The type of the element of the array is the called the base type of the array.
- The array will always be an object on the heap.
- What is the purpose of the volatile modifier?
Answer:
The volatile modifier tells the compiler that the variable modified by volatile can be changed unexpectedly by other parts of your program.
One of these situations involves multithreaded programs. In a multithreaded program, sometimes two or more threads share the same variable. For efficiency considerations, each thread can keep its own, private copy of such a shared variable.
- What is the difference between static methods and instance methods?
Answer:
The basic paradigm in Java is that you write Objects, and that those objects are instantiated. Instantiated objects (an instance of an object) have attributes associated with them (member variables) that affect their behavior; when the instance has its method executed it will refer to these variables.
A static method does not have an explicit reference to any particular instance of the class.
- How can you remember the number of bits of a float and double datatype?
Answer:
Float is 32 bit and double is 64 bits.
- What does it mean if a developer is programming to an interface?
Answer:
Programming to an interface is the concept that code should interact based on a defined set of functionality instead of an explicitly defined object type.
- What kind of datatypes can characters accept?
Answer:
- Integers
- hexadecimal
- octal
- character literals
- Can a static method call a non-static method?
Answer:
No.
- What do static methods have access to?
Answer:
Static methods can access only other static methods and variables.
- What are the this and super keywords used for in Java?
Answer:
The this and super keywords are used to access Java elements explicitly in relation to the current class.