The IT Certification Resource Center

Featured Deal

Get CompTIA, Cisco, and Microsoft training courses free for a week.
Learn More ❯

Question 11:

What will be printed when you execute the following code?

class X 
{
    Y b = new Y();
    X() 
    { 
        System.out.print("X"); 
    }
}
class Y 
{
    Y() 
    { 
        System.out.print("Y"); 
    }
}
public class Z extends X 
{
    Y y = new Y();
    Z() 
    { 
        System.out.print("Z"); 
    }
    public static void main(String[] args) 
    {
           new Z();
    }
}
A. Z
B. YZ
C. XYZ
D. YXYZ