Methods Flashcards

1
Q

What is the initialization order of a class?

A
  1. Static statements/blocks in the order they were defined.
  2. Instance initializer statements in the order defined.
  3. Constructor.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

When is a method considered to be overloaded?

A

When it has the same name as a parent class method but different parameters.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Is the following valid syntax for a method?

return this(a, b, c);

A

No.

This is valid syntax for a constructor.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

T/F: You cannot override the toString( ) method of the Object class.

A

False.

You sure can. The method toString( ) is defined as public and non-final in the Object class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Can static methods be accessed by the non-static keyword this?

A

Yes. Static methods can be accessed via static and non-static methods.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does the toString( ) method of the Object class return?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the reference type of the following code?

List list = new ArrayList( );

A

The reference type is ArrayList.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the object type of the following declaration?

List list = new ArrayList( );

A

The object type is List.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly