Home » JAVA Programming » Object & Classes » Question
  1. What is the output of this program?

    class N
    {
    int K;
    int L;
    N()
    {
    K = 1;
    L = 2;
    }
    }
    public class Result
    {
    public static void main(String args[])
    {
    N obj = new N();
    System.out.print(obj.toString());
    }
    }
    1. false
    2. Compilation Error
    3. true
    4. String associated with obj
    5. None of these
Correct Option: D

toString() is method of class Object, since it is superclass of every class, every object has this method. toString() returns the string associated with the calling object.
output: N@2a139a55



Your comments will be displayed only after manual approval.