What is the output of this program?
class A { int i; public void display() { System.out.println(i); } } class B extends A { int j; public void display() { System.out.println(j); } } class Dynamic_dispatch { public static void main(String args[]) { B obj2 = new B(); obj2.i = 1; obj2.j = 2; A r; r = obj2; r.display(); } }
What is the output of this program?
class binary { public static void main(String args[]) { int num = 17; System.out.print(Integer.toBinaryString(num)); } }
What is the output of this program?
class A { public void display() { System.out.println("A"); } } class B extends A { public void display() { System.out.println("B"); } } class Dynamic_dispatch { public static void main(String args[]) { A obj1 = new A(); B obj2 = new B(); A r; r = obj1; r.display(); r = obj2; r.display(); } }
What is the output of this program?
class area { int width; int length; int volume; area() { width = 5; length = 6; } void volume() { volume = width * height * length; } } class cons_method { public static void main(String args[]) { area obj = new area(); obj.volume(); System.out.println(obj.volume); } }
What is the output of this program?
class area { int width; int length; int volume; area() { width=5; length=6; } void volume() { volume = width*length*height; } } class cons_method { public static void main(String args[]) { area obj = new area(); obj.volume(); System.out.println(obj.volume); } }