Java_Interview_Questions_Answers
Java_Interview_Questions_Answers
Java Basics
Performance, Dynamic.
A: Java source code (.java) is compiled by javac to bytecode (.class), which is executed by the JVM.
A: Java has 8 primitive types: byte, short, int, long, float, double, char, and boolean.
Control Structures
System.out.println(i);
Example:
switch(day) {
default: System.out.println("Invalid");
OOPs Concepts
A: Class: blueprint
Q: What is inheritance?
Q: Overloading vs Overriding?
Q: What is abstraction?
A: Hiding implementation, showing only functionality. Achieved using abstract class or interface.
Q: What is an interface?
A: A contract with method declarations. All methods are public and abstract by default.
Q: What is polymorphism?
A: Ability to take many forms. Example: method overriding.
Q: What is encapsulation?
A: Binding data and code into a single unit (class). Fields are private, access via getters/setters.
Exception Handling
Q: Purpose of try-catch-finally?
Miscellaneous
Q: What is a constructor?
Q: What is a package?
A: A namespace that organizes classes and interfaces.