public class Username {
public void method(String name, int id) {
System.out.println("Method 1");
}
public void method(int id, String name) {
System.out.println("Method 2");
}
public static void main(String[] args) {
Username obj = new Username();
obj.method(23, "Hello");
obj.method("Hello", 23);
}
}
Program 2:
class MobileOS{
public void display() {
System.out.println("Mobile os");
}
}
class Android extends MobileOS{
public void display() {
System.out.println("Android");
}
}
class iOS extends MobileOS{
public void display() {
System.out.println("iOS");
}
}
public class OS {
public static void main(String[] args) {
Android obj1 = new Android();
iOS obj2 = new iOS();
obj1.display();
obj2.display();
}
}
0 Comments