MCQs > IT & Programming > Java > Output of the following program? public class Test { public static void main (String args[ ]) { B o = new A (); System.out.println (o.content ()); } public String content () throws Exception { throw new Exception (''This is an exception on this.content ()''); } private static class B { public String content () { return ''B''; } } private static class A extends B { public String content () { return ''A''; } } }

Java MCQs

What will be the output of the following program?

 public class Test
 {
     public static void main (String args[ ])
     {
         B o = new A ();
         System.out.println (o.content ());
     }
     public String content () throws Exception
     {
         throw new Exception (''This is an exception on this.content ()'');
     }
     private static class B
     {
       public String content ()
         {
         return ''B'';
         }
      }
      private static class A extends B
 {
       public String content ()
         {
            return ''A'';
         }
      }
 }

Answer

Correct Answer: The code will compile and on running, it will print ''A''

Explanation:

Note: This Question is unanswered, help us to find answer for this one

Java Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it

search

Java Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it