0% found this document useful (0 votes)
5 views

Java Programs

The document covers various examples of Java classes, illustrating fundamental concepts such as class creation, object instantiation, and method implementation. Key examples include a Student class for displaying details, a Rectangle class for area calculation, a BankAccount class for managing deposits, a Circle class for calculating area and circumference, and a Temperature class for converting Celsius to Fahrenheit. Each example highlights specific programming concepts relevant to ICSE Class 10 Computer Applications.

Uploaded by

sanskruti tajne
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Java Programs

The document covers various examples of Java classes, illustrating fundamental concepts such as class creation, object instantiation, and method implementation. Key examples include a Student class for displaying details, a Rectangle class for area calculation, a BankAccount class for managing deposits, a Circle class for calculating area and circumference, and a Temperature class for converting Celsius to Fahrenheit. Each example highlights specific programming concepts relevant to ICSE Class 10 Computer Applications.

Uploaded by

sanskruti tajne
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

ICSE Class 10 Computer Applications Chapter 2: "Class as the Basis of All

Computation" (Morning Star Book).

1. Simple Class Example: Student Details


public class Student {
String name;
int age;

void display() {
System.out.println("Name: " + name);
System.out.println("Age: " + age);
}

public static void main(String[] args) {


Student s = new Student();
s.name = "Aarav";
s.age = 15;
s.display();
}
}

➔ Concept Covered: Class, Object, Data members, Member method

2. Rectangle: Calculate Area


public class Rectangle {
int length, breadth;

int area() {
return length * breadth;
}

public static void main(String[] args) {


Rectangle r = new Rectangle();
r.length = 10;
r.breadth = 5;
System.out.println("Area: " + r.area());
}
}

➔ Concept Covered: Methods returning value, object creation

3. Bank Account: Deposit and Display


public class BankAccount {
String customerName;
double balance;
void deposit(double amount) {
balance += amount;
}

void display() {
System.out.println("Customer: " + customerName);
System.out.println("Balance: Rs. " + balance);
}

public static void main(String[] args) {


BankAccount acc = new BankAccount();
acc.customerName = "Riya Sharma";
acc.balance = 2000;
acc.deposit(1500);
acc.display();
}
}

➔ Concept Covered: Passing value through method, Data update

4. Circle: Calculate Area and Circumference


public class Circle {
double radius;

double area() {
return 3.14 * radius * radius;
}

double circumference() {
return 2 * 3.14 * radius;
}

public static void main(String[] args) {


Circle c = new Circle();
c.radius = 7;
System.out.println("Area: " + c.area());
System.out.println("Circumference: " + c.circumference());
}
}

➔ Concept Covered: Multiple methods in a class

5. Temperature Converter: Celsius to Fahrenheit


public class Temperature {
double celsius;

double toFahrenheit() {
return (celsius * 9/5) + 32;
}

public static void main(String[] args) {


Temperature t = new Temperature();
t.celsius = 25;
System.out.println("Temperature in Fahrenheit: " +
t.toFahrenheit());
}
}

➔ Concept Covered: Mathematical calculation using method

You might also like