Anasayfa
/
Teknoloji
/
Q4. Write the Exact Output of the Given Program into the Box. Public Class A Public Int A; Private Int B; Protected Int C; Public

Soru

Q4. Write the Exact output of the given program into the box. public class A public int a; private int b; protected int c; public static int d -0; A(int m,int n) f a=m; b=n;System.out.println("A is created"); d++; public void showb ) [ System.out.println ("b=+b); } public class B extends A public int a; private int p; B(int z1,int z2 int 23,int z4,int 25) super(z1,22); a=23; C=24;p=25; System.out.println("B is created"); public void showd ()System.out.println ("d=*+d ); ] public void showa ([ System.out.println ("a's are: "ta:" "super.a); ] public class Main square

Çözüm

3.2 (299 Oylar)
Berkay
Uzman doğrulaması
Uzman · 3 yıl öğretmeni

Cevap

The given program has several syntax errors and missing semicolons. Here is the corrected version of the program:```javapublic class A { public int a; private int b; protected int c; public static int d = 0; public A(int m, int n) { a = m; b = n; System.out.println("A is created"); d++; } public void showb() { System.out.println("b=" + b); }}public class B extends A { public int a; private int p; public B(int z1, int z2, int z3, int z4, int z5) { super(z1, z2); a = z3; c = z4; p = z5; System.out.println("B is created"); } public void showd() { System.out.println("d=" + d); } public void showa() { System.out.println("a's are: " + a + " " + super.a); } public static void main(String[] args) { B obj = new B(1, 2, 3, 4, 5); obj.showd(); obj.showa(); }}```The output of the corrected program will be:```B is createdd=1a's are: 3 1```