UNIT 1 Notes – Java Programming
1. Basics of Object Oriented Programming (OOP)
OOP is a programming method based on objects, classes, and real-world entities.
Main Features:
• Class – Blueprint/template for objects
• Object – Instance of a class
• Encapsulation – Wrapping data + methods into one unit
• Inheritance – One class acquires properties of another class
• Polymorphism – One function, many forms
• Abstraction – Showing essential features, hiding details
2. Difference Between C and Java
• C is procedure oriented, Java is object oriented
• C is platform dependent, Java is platform independent
• C uses pointers, Java does not
• C has no classes, Java uses classes
• Java supports garbage collection
3. Features of Java
• Simple • Secure • Portable • Object Oriented
• Platform Independent • Robust • Multithreaded
• Distributed • High Performance
4. Classes and Objects
class Student {
int id;
String name;
}
Object creation:
Student s1 = new Student();
5. Structure of Java Program
class Hello {
public static void main(String args[]) {
[Link]("Hello World");
}
}
6. Data Types
byte, short, int, long, float, double, char, boolean
7. Variables
Variable is a named memory location to store data.
Types:
• Local Variable
• Instance Variable
• Static Variable
8. Operators
Arithmetic: + - * / %
Relational: == != > <
Logical: && || !
Assignment: = += -=
Increment: ++ --
9. Java Environment
JDK = Java Development Kit
JRE = Java Runtime Environment
JVM = Java Virtual Machine
Flow:
Java Program → Compiler → Bytecode → JVM → Output
10. Methods
Method is a block of code used to perform a task.
void display() {
[Link]("Hello");
}
11. Constructor
Special method used to initialize object.
Same name as class.
class Student {
Student() {
[Link]("Constructor called");
}
}
Types:
• Default Constructor
• Parameterized Constructor
Important Questions:
2 Marks:
Define Class and Object, What is JVM, What is Constructor, List features of Java, What is Variable, Define OOP, What is JDK
5 Marks:
Explain Features of Java, Difference between C and Java, Explain Data Types and Variables, Explain JDK/JVM/JRE, Explain
10 Marks:
Explain OOP concepts, Explain Java Environment, Explain Class/Object/Constructor, Explain Operators in Java