0% found this document useful (0 votes)
2 views5 pages

Java Assignment

The document outlines a series of Java programming experiments focused on object-oriented programming concepts. It includes specific tasks such as displaying student information, demonstrating variable types, and implementing classes with attributes and methods. Each experiment is accompanied by code examples and explanations of key programming structures and concepts.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views5 pages

Java Assignment

The document outlines a series of Java programming experiments focused on object-oriented programming concepts. It includes specific tasks such as displaying student information, demonstrating variable types, and implementing classes with attributes and methods. Each experiment is accompanied by code examples and explanations of key programming structures and concepts.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

UNIVERSITY INSTITUTE OF ENGINEERING

Subject Name –OOPs Using JAVA

Subject Code – 24CSH-207

Submitted To: Submitted By:


Mr. Parvesh Kumar Name: Khushal Chaudhary
UID: 24BCS10033

Section:24BCS_SAP-612(A)
Department of Computer Science & Engineering

INDEX
Exp. List of Experiments Date
No

1) Write a Java program to display basic information about a 4/3/26


student (name, roll number, course, and semester).
Explain the structure of the program, use of
the class keyword, main() method, and output statements.

2) Write a Java program that demonstrates the difference between 4/3/26


local variables, instance variables, and static variables.
Analyze the scope and lifetime of each type of variable with
appropriate output and explanation.

3) Design and implement a Java program to demonstrate object- 4/3/26


oriented concepts.
Create a class with attributes and methods, instantiate objects in
the main() method, and explain how Java supports object-oriented
programming through this example.
Write a Java program to display basic information about a student (name, roll number,
course, and semester).
Explain the structure of the program, use of the class keyword, main() method, and output
statements.
class StudentInfo {
public static void main(String[] args) {
String name = "Khushal";
int rollNumber = 33;
String course = "BTech CSE";
int semester = 4;

[Link]("Student Information");
[Link]("Name: " + name);
[Link]("Roll Number: " + rollNumber);
[Link]("Course: " + course);
[Link]("Semester: " + semester);
}
}

Write a Java program that demonstrates the difference between local variables, instance
variables, and static variables.
Analyze the scope and lifetime of each type of variable with appropriate output and
explanation.

class VariableDemo {

int instanceVar = 10;


static int staticVar = 20;

void display() {
int localVar = 30;
[Link]("Instance Variable: " + instanceVar);
[Link]("Static Variable: " + staticVar);
[Link]("Local Variable: " + localVar);
}

public static void main(String[] args) {


VariableDemo obj1 = new VariableDemo();
VariableDemo obj2 = new VariableDemo();

[Link]();
[Link]();
}
}

Design and implement a Java program to demonstrate object-oriented concepts.


Create a class with attributes and methods, instantiate objects in the main() method, and
explain how Java supports object-oriented programming through this example.

class Student {

String name;
int rollNo;

void display() {
[Link]("Name: " + name);
[Link]("Roll Number: " + rollNo);
}

public static void main(String[] args) {


Student s1 = new Student();
Student s2 = new Student();
[Link] = "Khushal";
[Link] = 33;

[Link] = "Rahul";
[Link] = 45;

[Link]("Student 1 Details");
[Link]();

[Link]("Student 2 Details");
[Link]();
}
}

You might also like