Object & Classes


  1. What is the output of this program?
    class N
    {
    int p;
    double q;
    }
    class M extends N
    {
    int r;
    }
    public class Result
    {
    public static void main(String args[])
    {
    N p = new N();
    M q = new M();
    Class object;
    object = q.getClass();
    System.out.print(object.getSuperclass());
    }
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    getSuperClass() returns the super class of an object. q is an object of class M which extends class N , Hence Super class of q is N. therefore class N is printed.


  1. What is the output of this program?
    class N
    {
    int p;
    double q;
    }
    class M extends N
    {
    int r;
    }
    public class Result
    {
    public static void main(String args[])
    {
    N p = new N();
    M q = new M();
    Class object;
    object = q.getClass();
    System.out.print(object.isLocalClass());
    }
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    False



  1. Which of these classes is not included in java.lang?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Array class is a member of java.util.


  1. Which of these is a process of converting a simple data type into a class?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    type wrapping



  1. Which of these is a super class of wrappers Double & Integer?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    Number is an abstract class containing subclasses Double, Float, Byte, Short, Integer and Long.