Exp-2 Java
Exp-2 Java
Output:
Explanation:
import java.util.*;
// Define a class
class Student {
// Attributes
String name;
int age;
// Main class
public class StudentDemo {
public static void main(String[] args) {
// Create an object of the Student class
Student s1 = new Student();
Output:
Student Name: John
Student Age: 20
Explanation:
1. Class Student:
o Has two attributes: name and age.
o A method display() prints student details.