Which of the following options can be inserted at the commented line to compile the given code:

Code
  1. public class Class1 {

  2. Class1(String s){ }

  3. Class1() { }

  4. }

  5. class Class2 extends Class1{

  6. Class2(){ }

  7. Class2(String s) {super(s);}

  8. void m1() {

  9. // insert code here

  10. }

  11. }
Copyright GeekInterview.com

a) Class1 c1 = new Class1("HCL"){ }

b) Class1 c1 = new Class2(){ };

c) Class2 c3 = new Class1(String s){};

d) Class1 c1 = new Class1(100){ };

Questions by lalithakasiraj

Showing Answers 1 - 4 of 4 Answers

sashank

  • Dec 22nd, 2012
 

b) Class1 c1 = new Class2(){ };

  Was this answer useful?  Yes

Prasad MN

  • Dec 28th, 2012
 

Class c1 = new Class2()

Somone

  • Mar 29th, 2013
 

a & b

  Was this answer useful?  Yes

Abhinav Rohatgi

  • Apr 1st, 2013
 

Both a & b

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions