Java Diploma Short Notes
JAVA LAB MANUAL – SHORT NOTES FOR DIPLOMA EXAM
WEEK 1 – Java Installation & First Program
• Install Java JDK and Eclipse IDE
• Create Java Project → Create Class → Run Program
• Java file (.java) → Bytecode (.class) → JVM → Machine Code
• WORA = Write Once Run Anywhere
WEEK 2 – Variables & Datatypes
Primitive Datatypes:
int, float, double, char, byte, short, boolean, long
Increment Operators:
i++ = Post Increment
++i = Pre Increment
Boxing: Primitive → Wrapper
Unboxing: Wrapper → Primitive
WEEK 3 – Constructors
Constructor initializes object.
Types:
1. Default Constructor
2. Parameterized Constructor
Features:
• Same name as class
• No return type
• Called automatically
WEEK 4 – JVM Memory
JConsole monitors JVM memory.
JVM loads class files, verifies bytecode and converts to machine code.
WEEK 5 – Control Statements
Decision Making:
• if
• if-else
• else-if ladder
• switch
Loops:
• while
• do-while
• for
WEEK 6 – Encapsulation
Wrapping data and methods into single unit.
Advantages:
• Data hiding
• Security
• Easy testing
SRP:
Single Responsibility Principle means one class should perform one task.
WEEK 7 – Arrays & Strings
Array:
Collection of similar datatype elements.
Advantages:
• Fast access
• Code optimization
Disadvantage:
• Fixed size
String Methods:
length(), equals(), substring(), replace(), trim(), toUpperCase()
WEEK 8 – Inheritance
Inheritance means acquiring properties of parent class.
Types:
1. Single Inheritance
2. Multilevel Inheritance
3. Hierarchical Inheritance
Advantages:
• Code reuse
• Method overriding
WEEK 9 – Binding
Static Binding:
Compile-time binding.
Dynamic Binding:
Runtime binding using method overriding.
WEEK 10 – Abstraction
Abstraction hides implementation details.
Ways:
1. Abstract Class
2. Interface
WEEK 11 – Exception Handling
Exception = Runtime error.
Types:
1. Checked Exception
2. Unchecked Exception
3. Error
Advantages:
• Prevents crash
• Maintains normal flow
IMPORTANT VIVA QUESTIONS
1. Why Java is platform independent?
Because JVM executes bytecode on any OS.
2. Difference between constructor and method?
Constructor initializes object; method performs operation.
3. Difference between abstract class and interface?
Abstract class can contain normal methods; interface contains abstract methods.
4. Difference between while and do-while?
while checks condition first; do-while executes once first.
5. What is encapsulation?
Wrapping data and methods into one unit.