Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What is the output of the following code? 10 points 8 14 3 public class A { 4 public static void main(String[] args) throws Exception

image text in transcribedimage text in transcribed

What is the output of the following code? 10 points 8 14 3 public class A { 4 public static void main(String[] args) throws Exception { 5 B[] arr = new B[] { new c(), (new A()).new D(), (new B() { void m1() throws Exception { 7 System.out.println("NULL"); } 9 }) }; 10 for ( Bx: arr) { 11 x.m1(); 12 } 13 } private class D extends B { 15 void m1() { 16 try { 17 if (value == 0) throw new Exception("error"); 18 System.out.println("Value is a positive number."); 19 } catch (Exception e) { 20 System.out.println(e.getMessage()); 21 } 22 System.out.println("Value now is:"+ value); 23 } 24 } 25 } 26 interface I { 27 double Value = 4; 28 } System.out.println("Value is a positive number."); 19 } catch (Exception e) { 20 System.out.println(e.getMessage()); 21 } 22 System.out.println("Value now is:"+ value); 23 } 24 } 25 } 26 interface I { 27 double Value = 4; 28 } 29 abstract class B { 30 abstract void m1() throws Exception; 31 protected static int value = 1; 32 } 33 class C extends B implements I { 34. void m1() throws Exception { 35 if (value == 0) 36 throw new Exception ("value cannot be 0"); 37 System.out.println("Value: + (2*Value / value)); 38 } 39 }

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

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

More Books

Students also viewed these Databases questions

Question

What is the principle of thermodynamics? Explain with examples

Answered: 1 week ago

Question

Explain the strength of acid and alkali solutions with examples

Answered: 1 week ago