INTRODUCTION TO CLASSES AND METHODS MCQS 04
1) Which of the following can be referenced by this variable?
a.The instance variables of a class only
b.The methods of a class only
c.The instance variables and methods of a class
Ans: c.
2) The this reference is used in conjunction with ___methods.
a.static
b.non-static
Ans: b.
3) Which of the following operators are used in conjunction withthe this and super references?
a.The new operator
b.The instanceof operator
c.The dot operator
Ans: c.
4) A constructor is automatically called when an object is instantiated
a. true
b. false
Ans: a.
5) When may a constructor be called without specifying arguments?
a. When the default constructor is not called
b. When the name of the constructor differs from that of the class
c. When there are no constructors for the class
Ans: c.
6) Each class in java can have a finalizer method
a. true
b.false
Ans: a.
7) When an object is referenced, does this mean that it has been identified by the finalizer method for garbage collection?
a.yes
b.no
Ans: b.
8) Because finalize () belongs to the java.lang.Object class, it is present in all ___.
a.objects
b.classes
c.methods
Ans: b.
9) Identify the true statements about finalization.
a.A class may have only one finalize method
b.Finalizers are mostly used with simple classes
c.Finalizer overloading is not allowed
a.The instance variables of a class only
b.The methods of a class only
c.The instance variables and methods of a class
Ans: c.
2) The this reference is used in conjunction with ___methods.
a.static
b.non-static
Ans: b.
3) Which of the following operators are used in conjunction withthe this and super references?
a.The new operator
b.The instanceof operator
c.The dot operator
Ans: c.
4) A constructor is automatically called when an object is instantiated
a. true
b. false
Ans: a.
5) When may a constructor be called without specifying arguments?
a. When the default constructor is not called
b. When the name of the constructor differs from that of the class
c. When there are no constructors for the class
Ans: c.
6) Each class in java can have a finalizer method
a. true
b.false
Ans: a.
7) When an object is referenced, does this mean that it has been identified by the finalizer method for garbage collection?
a.yes
b.no
Ans: b.
8) Because finalize () belongs to the java.lang.Object class, it is present in all ___.
a.objects
b.classes
c.methods
Ans: b.
9) Identify the true statements about finalization.
a.A class may have only one finalize method
b.Finalizers are mostly used with simple classes
c.Finalizer overloading is not allowed
d. both a and c
Ans: d.
10) When you write finalize() method for your class, you are overriding a finalizer inherited from a super class.
a.true
b.false
Ans: a.
Ans: d.
10) When you write finalize() method for your class, you are overriding a finalizer inherited from a super class.
a.true
b.false
Ans: a.
No comments:
Post a Comment