Cycle 02
Lab Cycle 2 — OOP Concepts
Class and Object
Problem Statement
Write a Java program to demonstrate class and object creation.
class Student {
String name;
int age;
void display() {
System.out.println("Name: " + name + ", Age: " + age);
}
}
public class Main {
public static void main(String[] args) {
Student s1 = new Student();
s1.name = "Alice";
s1.age = 20;
s1.display();
}
}
Question 1 of 5