Oracle 1Z0-808 Exam question no. 29

Q.- Given the code fragment:-

public class Person { 
          String name; 
          int age = 25; 
          Person (String name) {                               // line n1
               setName (name); 
          }
          public Person (String name, int age)   {
               Person (name);                                     // line n2 
               setAge (age); 
          }

         // setter and getter methods go here

          public String show(  ) { 
                   return name + " " + age; 
          }
          public static void main(String[ ] args)   {
                   Person p1 = new Person ("Jesse"); 
                   Person p2 = new Person ("Walter", 52); 
                   System.out.println (p1.show()); 
                   System.out.println (p2.show()); 
          }
}

What is the result? 

A) Jesse 25 
     Walter 52 

B) Compilation fails at both line n1 and line n2. 

C) Compilation fails only at line n1. 

D) Compilation fails only at line n2.


⧪ please give your answer in a comment section.

Post a Comment

6 Comments