Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

OUTPUT OF THIS CODE public class A { public static void main(String [] args) throws Exception { B[] arr = new B[] {(new A()).new C(),

OUTPUT OF THIS CODE

public class A { public static void main(String [] args) throws Exception { B[] arr = new B[] {(new A()).new C(), (new A()).new D(), (new B() { void m1()throws Exception{ System.out.println("NaN"); } })}; for(B x: arr) { x.m1(); } } private class D extends B{ void m1() { try { if(number %2 == 0) throw new Exception("Please insert an odd number."); System.out.println("You have inserted an odd number."); } catch (Exception e) { System.out.println(e.getMessage()); } System.out.println("Number is now: "+number); } } class C extends B implements I { void m1() throws Exception { if (number == 0) throw new Exception("Number cannot be 0"); System.out.println("Number: " + Number * number); } } } interface I{ double Number = 5; } abstract class B { abstract void m1() throws Exception; protected static int number = 8; protected B() { number++; System.out.println(number); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Expert Oracle Database Architecture

Authors: Thomas Kyte, Darl Kuhn

3rd Edition

1430262990, 9781430262992

More Books

Students also viewed these Databases questions

Question

Bring out the limitations of planning.

Answered: 1 week ago

Question

Why should a business be socially responsible?

Answered: 1 week ago

Question

Discuss the general principles of management given by Henri Fayol

Answered: 1 week ago

Question

Detailed note on the contributions of F.W.Taylor

Answered: 1 week ago

Question

Is how things are said consistent with what is said?

Answered: 1 week ago

Question

Do you currently have a team agreement?

Answered: 1 week ago

Question

c. How is trust demonstrated?

Answered: 1 week ago