Question

What is the output of running class C? The three Java classes are in separate Java files in the same directory (or in the sam
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Output-

The Default constructor of A
B rocks!
Hi from C

Explanation - We we run C program . It will start running from top . So first B b = new B("B rocks"); will run and it will go to class B. In B class by using extends it call class A so first class A will run the class A then return to class B and run program and return back to class C and run the rest of the program.

Add a comment
Know the answer?
Add Answer to:
What is the output of running class C? The three Java classes are in separate Java...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Java questions QUESTION 8 Assume the following classes are each defined in their own java files...

    Java questions QUESTION 8 Assume the following classes are each defined in their own java files and compile public class A public void display { System.out.println("A's display"); public class B extends A{ public void display { System.out.println("B's display"); public class C extends A public void display { System.out.println("C's display"); public class D { public static void main(String args) { 3: int i = ((int)(Moth.random(* 10)) if (i == 0) a = new BO: else if (i == 1) a =...

  • Show the output of running the class Test in the following code lines: interface A {...

    Show the output of running the class Test in the following code lines: interface A { void print (); } class C ( class B extends C implements A { public void print() { } } class Test { public static void main(String[] args) { B b = new B(); if (b instanceof A) System.out.println("b is an instance of A"); w class Test { public static void main(String[] args) { B b = new B(); if (b instanceof A) System.out.println("b...

  • Show the output of running the class Test in the following code lines: a) Nothing. b)...

    Show the output of running the class Test in the following code lines: a) Nothing. b) b is an instance of A followed by b is an instance of c c) b is an instance of C d) b is an instance of A interface A { void print (); } class C {} class B extends c implements A { public void print() { } } class Test { public static void main(String[] args) { B b = new...

  • Draw a UML class diagram (with associations) to show the design of the Java application. public...

    Draw a UML class diagram (with associations) to show the design of the Java application. public class OOPExercises {     public static void main(String[] args) {         //A objA = new A();         B objB = new B();         System.out.println("in main(): ");         //System.out.println("objA.a = "+objA.getA());         System.out.println("objB.b = "+objB.getB());         //objA.setA (222);         objB.setB (333.33);         //System.out.println("objA.a = "+objA.getA());         System.out.println("objB.b = "+objB.getB());     } } public class A {     int a = 100;     public A() {...

  • Filename(s): ReformatCode. java Public class: ReformatCode Package-visible class(es): none Write a program that reformats Java source...

    Filename(s): ReformatCode. java Public class: ReformatCode Package-visible class(es): none Write a program that reformats Java source code from the next-line brace style to the end-of-line brace style. The program is invoked from the command line with the input Java source code file as args [0] and the name of the file to save the formatted code in as args [1]. The original file is left untouched. The program makes no other changes the source code, including whitespace. For example, the...

  • i think from the very bottom part there, they just want to know what the output...

    i think from the very bottom part there, they just want to know what the output would be when you call the main() method of the Maryland class workout actually running it. 2. Consider the following code fragment taken from some package: public class Maryland extends State { Maryland() /* null constructor */ ) public void printMe() ( System.out.printin("Read it."); } public static void main(String[] args) Region mid = new State(); State md new Maryland(); Object obj new Place(); Place...

  • 2016 points output of following Java Program? public class Base { public final void show() {...

    2016 points output of following Java Program? public class Base { public final void show() { . System.out.println("Base::show() called"); public class Derived extends Base { public void show() { System.out.println("Derived::show() called"); } e lor rested in order public class Main { ects from and public static void main(String[] args) { Base b = new Derived(); b.show();

  • Assume we have these two classes. Note that they are in separate packages. If the code...

    Assume we have these two classes. Note that they are in separate packages. If the code works, tell me what it prints. Otherwise, tell me (in your own words) why it doesn’t work. ● In one package: public class MyClass { int x = 5; } ● In another package: public class Main { public static void main(String args) { MyClass obj = new MyClass(); System.out.println(obj.x); } }

  • easy question but i am confused. someone help Consider the following Java classes: class OuterClass {...

    easy question but i am confused. someone help Consider the following Java classes: class OuterClass { static class InnerClass { public void inner Method({ System.out.println("This is my inner class"); public static void outer Method{ System.out.println("This is my outer class"); public class OuterClass Test{ public static void main(String args[]) { Complete the class OuterClass Test to produce as output the two strings in class OuterClass. What are the outputs of your test class?

  • help me with a question in java: class A { int i = 10; } class...

    help me with a question in java: class A { int i = 10; } class B extends A { int i = 20; } public class Boo { public static void main(String[] args) { A a = new B(); System.out.println(a.i); } }

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT