[01 Mark] public class MethodOverloadingi void show(int a, char b) { System.out.println("KING KONG"); } void show(char a
Posted: Sun May 15, 2022 1:09 pm
[01 Mark] public class MethodOverloadingi void show(int a, char b) { System.out.println("KING KONG"); } void show(char a, int b) { System.out.println("JIM JAM"); } public static void main(String[] args) { Methodoverloadingi m = new MethodOverloading1(); m.show(10, 'A'); m.show('B', 10); m.show(10, 'A'); 5 } [01 Mark] class Person { public void talk() { System.out.print("First Program"); ) } class Student extends Person public void talk() { System.out.print("Second Program"); > } public class Test Program public static void main(String args[]) { Person p = new Student (); p.talk(); } }
public interface Calculate (void cal(int item); int sampleMethod (int y);} class Display implements Calculate { int x; public void cal(int item) { x = it item . item;} public int sampleMethod (int y) {return x + y;) } public class Interfaces { public static void main(String args[]) { Display arr = new Display(); arr.x=; arr.cal(2); System.out.print(arr.x);} 7 } abstract class Coffee { Coffee) {System.out.println("Inside Constructor of Coffee..");) class ColdCoffee extends Coffee { ColdCoffee() {System.out.println("Inside Constructor of ColdCoffee.."); } public class AbstractClassTesting { public static void main(String[] args) { ColdCoffee cf = new ColdCoffee(); } 8
Public interface Test Interface Int i = 10; } Public class Test { public static void main(String[] args) { int i= 12; System.out.println(Test Inter.i);} enum Color RED, GREEN, BLUE; } public class Test { // Driver method public static void main(String[] args) 10 { Color c1 = Color.RED; System.out.println(c1); } }
public interface Calculate (void cal(int item); int sampleMethod (int y);} class Display implements Calculate { int x; public void cal(int item) { x = it item . item;} public int sampleMethod (int y) {return x + y;) } public class Interfaces { public static void main(String args[]) { Display arr = new Display(); arr.x=; arr.cal(2); System.out.print(arr.x);} 7 } abstract class Coffee { Coffee) {System.out.println("Inside Constructor of Coffee..");) class ColdCoffee extends Coffee { ColdCoffee() {System.out.println("Inside Constructor of ColdCoffee.."); } public class AbstractClassTesting { public static void main(String[] args) { ColdCoffee cf = new ColdCoffee(); } 8
Public interface Test Interface Int i = 10; } Public class Test { public static void main(String[] args) { int i= 12; System.out.println(Test Inter.i);} enum Color RED, GREEN, BLUE; } public class Test { // Driver method public static void main(String[] args) 10 { Color c1 = Color.RED; System.out.println(c1); } }