Consider the following class: //class M public abstract clas…

Consider the following class: //class M public abstract class M { private int n; protected double p; public abstract void foo1(); } //end class M   Answer the following questions: 1. If you code the following class: public class P extends M { }    When you compile the code, what is the result? 2. If you code the following class: public class P extends M { public void foo1() { System.out.println(“n is: ” + n); } } When you compile the code, what is the result? 3. If you code the following classes, P and Q: public class P extends M { public P(double newP) { p = newP; } public void foo1() { } }//end class P   public class Q extends P { private int z; public Q(double newP, int newZ) { z = newZ; super(newP); } } When you compile the code, what is the result?

You have a tryblock that might throw a user-defined exceptio…

You have a tryblock that might throw a user-defined exception TooYoungException or any type of Exception . Put these exceptions in the correct order in the catch blocks       try      {      // statements which might throw any type of Exception      // or TooYoungException      }            catch ([b1]  ex )      {      // statements to handle this      // type of exception      }            catch ([b2]   ex  )      {      // statements to handle this      // type of exception      }      // Statements following the structure

Consider the following two classes:   And assuming that the…

Consider the following two classes:   And assuming that the following variable has been declared: Car mycar = new Truck(); 1. What is the output or result from the following statement? mycar.m1();  2. What is the output or result from the following statement? mycar.m2();  

Consider the following three classes: public class A { priva…

Consider the following three classes: public class A { private int number; protected String name; public double price; public A() {  … } private void foo1() { System.out.print(“A version of foo1() called.”); } protected int foo2() { System.out.print(“A version of foo2() called.”); return number; } public String foo3() { System.out.print(“A version of foo3() called.”); return “Hi!”; } }  //end class A   public class B extends A { private char service; public B() {  … } public void foo1() { System.out.print(“B version of foo1() called.”); } public int foo2() { int n = super.foo2(); System.out.print(“B version of foo2() called.”); return n + 5; } public String foo3() { String temp = super.foo3(); System.out.print(“A version of foo3() called.”); return temp + ” foo3.”; } }  //end class B   public class C extends B { public C() {  … } public void foo1() { System.out.print(“C version of foo1() called.”); } }  //end class C Answer the following questions: 1. The instance data members are inherited by B class from A class are [ans1]  and [ans2]. 2. The instance methods are inherited by B class from A class are [ans3] and [ans4].  (For the answers to the following questions, watch out space!) 3. What is the output of the following code sequence? B b1 = new B(); b1.foo1();  [ans5] 4. What is the output of the following code sequence? B b2 = new B(); int n = b2.foo2();  [ans6] 5. What is the output of the following code sequence? B b3 = new B(); System.out.print(b3.foo3());  [ans7] 6. What is the output of the following code sequence? C c1 = new C(); c1.foo1();  [ans8]