adplus-dvertising
frame-decoration

Question

What is the output of this program?
    class X 
    {
        int a;
        double b;
    }
    class Y extends X 
    {
 int c;
    }
    class Output 
    {
        public static void main(String args[]) 
        {
            X a = new X();
            Y b = new Y();
            Class obj;
            obj = a.getClass();
            System.out.print(obj.getName());
        }
    }

a.

X

b.

Y

c.

a

d.

b

Posted under Java Programming

Answer: (a).X

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of this program?

Similar Questions

Discover Related MCQs

Q. Which of the interface contains all the methods used for handling thread related operations in Java?

Q. Which of these class is used to make a thread?

Q. Which of this interface is implemented by Thread class?

Q. Which of these methods of a Thread class is used to suspend a thread for a period of time?

Q. Which object Java application uses to create a new process?

Q. Which of the following is true about Java system properties?

Q. Java system properties can be set at runtime.

Q. Which system property stores installation directory of JRE?

Q. What does System.getProperty(“variable”) return?

Q. What is true about the setProperties method?

Q. How to use environment properties in the class?

Q. How to assign values to variable using property?

Q. Which environment variable is used to set java path?

Q. How to read a classpath file?

Q. Which of the following would compile without error?

Q. Which of the following are valid calls to Math.max?

1. Math.max(1,4)
2. Math.max(2.3, 5)
3. Math.max(1, 3, 5, 7)
4. Math.max(-1.5, -2.8f)

Q. Which statement is true given the following?

Double d = Math.random();

Q. Which two statements are true about wrapper or String classes?

1. If x and y refer to instances of different wrapper classes, then the fragment x.equals(y) will cause a compiler failure.
2. If x and y refer to instances of different wrapper classes, then x == y can sometimes be true.
3. If x and y are String references and if x.equals(y) is true, then x == y is true.
4. If x, y, and z refer to instances of wrapper classes and x.equals(y) is true, and y.equals(z) is true, then z.equals(x) will always be true.
5. If x and y are String references and x == y is true, then y.equals(x) will be true.

Q. Which of the following will produce an answer that is closest in value to a double, d, while not being greater than d?

Q. What two statements are true about the result obtained from calling Math.random()?


1. The result is less than 0.0.
2. The result is greater than or equal to 0.0..
3. The result is less than 1.0.
4. The result is greater than 1.0.
5. The result is greater than or equal to 1.0.