Methods Flashcards
What is the initialization order of a class?
- Static statements/blocks in the order they were defined.
- Instance initializer statements in the order defined.
- Constructor.
When is a method considered to be overloaded?
When it has the same name as a parent class method but different parameters.
Is the following valid syntax for a method?
return this(a, b, c);
No.
This is valid syntax for a constructor.
T/F: You cannot override the toString( ) method of the Object class.
False.
You sure can. The method toString( ) is defined as public and non-final in the Object class.
Can static methods be accessed by the non-static keyword this?
Yes. Static methods can be accessed via static and non-static methods.
What does the toString( ) method of the Object class return?
It returns the name of the class of which the object is an instance, the at-sign character ‘@’, and the unsigned hexadecimal representation of the hash code of the object.
What is the reference type of the following code?
List list = new ArrayList( );
The reference type is ArrayList.
What is the object type of the following declaration?
List list = new ArrayList( );
The object type is List.