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 object = new N();
    System.out.print(object.toString());
    }
    }
    1. Compilation Error
    2. true
    3. false
    4. String associated with object
    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.



Your comments will be displayed only after manual approval.