Q) False statements about an Abstract class in java
- Abstract class act as a base class and can be extended
- Abstract class cannot be instantiated.
- It can contain only abstract methods.
- All of them are correct
Answer: 3
An abstract class in java can have both abstract and non-abstract methods.
Q) Correct differences between throw and throws in java is/are
- throw keyword is used to throw an exception explicitly whereas throws clause is used to declare an exception.
- By using Throw keyword, we cannot throw more than one exception but using throws we can declare multiple exceptions
- throw is used inside method body to invoke an exception and throws clause is used in method declaration (signature).
- All of them are correct.
Answer: 4
Q) Readonly variables in java
- Can be modified at runtime in non static constructor only.
- Can be modified from both method and constructor.
- Can never be modified as it behave as constant variable
- All are correct.
Answer: 1
Readonly variable can be modified in non-static constructor at run time.
const variable can never be modified across the program once initialized.
Read difference between readonly and const with example in C sharp
Q) In Java static variable is used to
- Refer common properties to all objects.
- get persistent value between different method call
- It gets memory only once in a class area at the time of class loading.
- All are correct
Answer: 4
Q) False statement about static method in java
- Belongs to class not object of the class
- Can be called without any object creation of a class
- Can access non static and static variables both.
- All are correct.
Answer: 3
Static method in java can access only static variables or static method.