1 Replies - 144 Views - Last Post: 10 April 2019 - 05:04 AM Rate Topic: -----

#1 dkg008   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 10-April 19

Can you tell me what will be the output of the following program?

Posted 10 April 2019 - 05:01 AM

What will be the output of the following program with explanation?
public class X {
	
  void draw(int a, float B)/> throws Throwable{
	  System.out.println("Circle");
  }
}
public class Y extends X {
	
@Override
void draw(int a, float B)/>{
	System.out.println("Rectangle");
}
}
public class Z extends Y {
	
  void draw(int a, float B)/> throws ArithmeticException{
	  System.out.println("Square");
  }
}
public class Test {
public static void main(String[] args) throws Throwable{
  Y y=(Y)x;
   y.draw(10,2.9f);
  Z z=(Z)y;
   z.draw(20, 30f);
	}

}



Is This A Good Question/Topic? 0
  • +

Replies To: Can you tell me what will be the output of the following program?

#2 andrewsw   User is online

  • quantum multiprover
  • member icon

Reputation: 6792
  • View blog
  • Posts: 28,045
  • Joined: 12-December 12

Re: Can you tell me what will be the output of the following program?

Posted 10 April 2019 - 05:04 AM

Run it and see what happens, then try to explain it.

Closing.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1