JAVA QUIZ
Question 1
Which of the following is false about a "super" call in a sub class's constructor?
Select one:
a. It must be the first statement in the constructor
b. If you don't include it Java will
c. If you don't include it you must have a 0 parameter constructor coded in the super class or no constructors coded at all in the super class
d. The sub class constructor containing the super call and the called super class constructor must have matching parameter lists (i.e. same number and type of parameters)
e. If you think none of the above are false, select this option
Question 2
Which of the following components of a super class is not inherited by its sub classes?
Select one or more:
a. Private methods
b. Static methods
c. Accessors
d. Constructors
e. Mutators
f. Public methods
g. Instance variables
h. Non-static methods
Question 3
Which of the following is sufficient for 2 methods to overload?
Note: sub/super means the methods are in two classes that are in an inheritance relationship.
Select one:
a. Same signature, same class
b. Different signature but same name, same class
c. Different signature including different name, same class
d. Different signature but same name, sub/super class
e. If you think more than one of the above are sufficient for 2 methods to overload, select this option
Question 4
In the inheritance scenario involving coding a core class with multiple specialised sub classes which of the following is least likely to be used?
Select one:
a. Adding new instance variables to a sub class
b. Adding new methods to a sub class
c. Overriding inherited methods in a sub class
d. Use of an abstract class
e. If you think none of the above are clearly the least likely to be used, select this option
Question 5
Which of the following is necessary for a method to override another method?
Note: sub/super means the methods are in two classes that are in an inheritance relationship.
Select one:
a. Same signature, same class
b. Same signature, sub/super class
c. Different signature but same name, sub/super class
d. Different signature including different name, sub/super class
e. If you think none of the above are what is necessary for a method to override another method, select this option
Question 6
Which of the following components of a super class cannot be called in its sub classes?
Select one:
a. Overridden methods
b. Constructors
c. Mutators
d. Accessors
e. Public methods
f. Private methods
g. If you believe all of the above components of a super class can be called in its sub classes, select this option
Question 7
In the inheritance scenario involving the reuse of an existing class which of the following is least likely to be used?
Select one:
a. Adding new instance variables to a sub class
b. Adding new methods to a sub class
c. Overriding inherited methods in a sub class
d. Use of an abstract class
e. If you think none of the above are clearly the least likely to be used, select this option
Question 8
Which of the following cannot be added to a sub class?
Select one:
a. New public class level variables
b. New private class level variables
c. New public methods
d. New private methods
e. If you think all of the above can be added to a sub class, select this option
Question 9
Which of the following members of a super class are only indirectly accessible in its sub classes?
Select one:
a. Private class level variables
b. Public class level variables
c. Private methods
d. Public methods
e. If you believe more than one of the above are only indirectly accessible in a sub class, select this option
Question 10
Which of the following is false about an empty class you have just coded.
Select one:
a. It has a super class
b. It has a toString method
c. It has a constructor
d. A subclass of it could be coded
e. Select this option if you think none of the above are false
Answers :
1. If you don't include it Java will
2. Private methods
3. If you think more than one of the above are sufficient for 2 methods to overload, select this option
4. Overriding inherited methods in a sub class
5. Different signature but same name, sub/super class
6. Private methods
7. Overriding inherited methods in a sub class
8. If you think all of the above can be added to a sub class, select this option
9. Public methods
10. Select this option if you think none of the above are false
Get Answers For Free
Most questions answered within 1 hours.