JAVA PROGRAMMING
UNIT 1
Introduction to Java:
Developed by James Gosling at Sun Microsystems. Java is a high-level, object-oriented programming language. It fol
Class
• A class is a blueprint or template used to create objects.
• It defines variables and methods.
Object
• An object is an instance of a class.
• It represents a real-world entity and uses the properties of a class.
Example
• For example, Car is a class and BMW, Audi are objects.
Example program to demonstrate class and object:
class Student {
int id;
String name;
void display() {
[Link](id + " " + name);
}
public static void main(String[] args) {
Student s1 = new Student();
[Link] = 1;
[Link] = "Bhavana";
[Link]();
}
}
Object-Oriented Programming (OOP) Paradigms
• OOP is based on classes and objects
• Improves code reusability
• Makes program easy to manage and secure
• Follows real-world approach
Pillars of OOPs:
1. Encapsulation
• Encapsulation means wrapping data and methods into a single unit (class).
• Data + Functions = One unit
2. Abstraction
• Abstraction means hiding internal details and showing only necessary information.
3. Inheritance
• Inheritance means one class can use properties of another class.
4. Polymorphism
• Polymorphism means one thing can have many forms.
Features of JAVA
• Object Oriented
• Platform Independent
• Interpreted
• Scalable
• Portable
• Secured and Robust
• Memory Management
• Multithreading
• Rich Standard Library
• Support for Mobile and Web Application
Structure of a Java Program:
package mypackage;
import [Link].*;
class Demo {
int x = 10;
void display() {
[Link]("Hello");
}
public static void main(String[] args) {
[Link]("Program starts here");
}
}
(remaining content continues exactly as provided in your notes...)