Java Quiz 10 : Classes and Methods I

    Welcome to your Java Quiz 10 : Classes and Methods I

    1. What is the stored in the object obj in following lines of Java code?
     box obj;
    2. Which of these keywords is used to make a class?
    3. Which of the following is a valid declaration of an object of class Box?
    4. Which of these operators is used to allocate memory for an object?
    5. Which of these statement is incorrect?
    6. What will be the output of the following Java program?
    1.  class main_class 
    2.  {
    3.  public static void main(String args[])
    4.  {
    5.  int x = 9;
    6.  if (x == 9) 
    7.  { 
    8.  int x = 8;
    9.  System.out.println(x);
    10.  }
    11.  } 
    12.  }
    7. Which of the following statements is correct?
    8. What will be the output of the following Java program?
    1.  class box 
    2.  {
    3.  int width;
    4.  int height;
    5.  int length;
    6.  } 
    7.  class mainclass 
    8.  {
    9.  public static void main(String args[]) 
    10.  { 
    11.  box obj = new box();
    12.  obj.width = 10;
    13.  obj.height = 2;
    14.  obj.length = 10;
    15.  int y = obj.width * obj.height * obj.length; 
    16.  System.out.print(y);
    17.  } 
    18.  }
    9. What will be the output of the following Java program?
    1.  class box 
    2.  {
    3.  int width;
    4.  int height;
    5.  int length;
    6.  } 
    7.  class mainclass 
    8.  {
    9.  public static void main(String args[]) 
    10.  { 
    11.  box obj1 = new box();
    12.  box obj2 = new box();
    13.  obj1.height = 1;
    14.  obj1.length = 2;
    15.  obj1.width = 1;
    16.  obj2 = obj1;
    17.  System.out.println(obj2.height);
    18.  } 
    19.  }
    10. What will be the output of the following Java program?
    1.  class box 
    2.  {
    3.  int width;
    4.  int height;
    5.  int length;
    6.  } 
    7.  class mainclass 
    8.  {
    9.  public static void main(String args[]) 
    10.  { 
    11.  box obj = new box();
    12.  System.out.println(obj);
    13.  } 
    14.  }
    11. What is the return type of a method that does not return any value?
    12. What is the process of defining more than one method in a class differentiated by method signature?
    13. Which of the following is a method having same name as that of it’s class?
    14. Which method can be defined only once in a program?
    15. Which of this statement is incorrect?