JAVA 2.2 To call the method print() of class Student first and then call print() method of class School

class School { 
public void print() {
System.out.println("Hi! I class SCHOOL.");
    }
}

class Student {
 public void print() {
System.out.println("Hi! I am class STUDENT");
    }
}
public class Question{
public static void main(String[] args) {
Student s1=new Student();
s1.print();
School s2=new School();
s2.print();



     }
}

No comments:

Post a Comment