Java Classes and Objects
Java Classes and Objects - Important Points
26. | Which of the following is true about static variables in Java? |
---|
A. They are created when an object is created.
B. They are stored in the heap memory.
C. They are shared among all objects of a class.
D. They can be accessed using object reference.
View Answer Discuss Work SpaceAnswer: option c
Explanation:
27. | Which of the following is true about instance variables in Java? |
---|
A. They are created when an object is created.
B. They are stored in the heap memory.
C. They are shared among all objects of a class.
D. They can be accessed using class name.
View Answer Discuss Work SpaceAnswer: option a
Explanation:
28. | Which of the following is true about local variables in Java? |
---|
A. They are declared inside a method or block.
B. They have default values.
C. They are initialized automatically.
D. They can be accessed from any method in the class.
View Answer Discuss Work SpaceAnswer: option a
Explanation:
29. | Which of the following is true about method overloading in Java? |
---|
A. It allows a method to have the same name and signature as another method in the same class.
B. It allows a method to have the same name and signature as a method in a different class.
C. It allows a method to have the same name but different signature as another method in the same class.
D. It allows a method to have a different name but same signature as another method in the same class.
View Answer Discuss Work SpaceAnswer: option c
Explanation:
30. | Which of the following is true about method overriding in Java? |
---|
A. It allows a subclass to provide its own implementation of a method in the superclass.
B. It allows a superclass to provide its own implementation of a method in the subclass.
C. It allows a method to have the same name but different signature as another method in the same class.
D. It allows a method to have a different name but same signature as another method in the same class.
View Answer Discuss Work SpaceAnswer: option a
Explanation: