JAVA VIVA QUESTIONS & ANSWERS
(1) What is Java?
Java is a high-level, object-oriented, platform-independent programming language.
(2) What are features of Java?
Object-Oriented, Platform Independent, Simple, Secure, Robust, Portable, Multithreaded.
(3) What is JDK, JRE, JVM?
JDK: Development kit. JRE: Runtime environment. JVM: Executes bytecode.
(4) What is a Class?
A blueprint containing data members and methods.
(5) What is an Object?
An instance of a class with state and behavior.
(6) What is a Constructor?
Special method to initialize objects.
(7) Types of Constructors:
Default, Parameterized, Copy.
(8) What is Method Overloading?
Same method name, different parameters.
(9) What is Method Overriding?
Child class defines its own version of a parent method.
(10) What is Inheritance?
One class acquiring properties of another.
(11) Types of Inheritance:
Single, Multilevel, Hierarchical.
(12) What is 'this' keyword?
Refers to current object.
(13) What is 'super' keyword?
Refers to parent class object.
(14) What is an Array?
Collection of similar data types.
(15) Types of Arrays:
1D and 2D.
(16) What is Polymorphism?
One action in many forms.
(17) What is 'final' keyword?
Used to restrict modification.
(18) What is 'static' keyword?
Belongs to class not object.
(19) Difference between this and super:
this = current class, super = parent class.
(20) What is Encapsulation?
Wrapping data and methods together.
(21) What is Abstraction?
Hiding implementation details.
(22) Can we overload constructors?
Yes.
(23) Can we override constructors?
No.
(24) What is super()?
Calls parent constructor.
(25) What is 2D array?
Array with rows and columns.
(26) Default array values:
int=0, boolean=false, object=null.
(27) What is method signature?
Method name + parameters.
(28) What is dynamic method dispatch?
Runtime selection of overridden method.
(29) Difference between Overloading and Overriding:
Overloading=compile time, Overriding=runtime.
(30) What is package?
Collection of classes.
(31-70) Additional Questions:
Includes class vs object, platform independence, bytecode, return statement, equals() vs ==, array
basics, constructor rules, abstract class, interface, access modifiers, encapsulation, recursion, garbage
collection, static rules, final rules, this() and super(), etc.