162). What is the stored in the object obj in following lines of Java code?
 box obj;

[A]Memory address of allocated memory of object
[B]NULL
[C] Any arbitrary pointer
[D]Garbage

Show Answer

165). Which of these operators is used to allocate memory for an object?
 box obj;

[A]malloc
[B]alloc
[C]new
[D]give

Show Answer

166). Which of these statement is incorrect?
 box obj;

[A] Every class must contain a main() method
[B]Applets do not require a main() method at all
[C]There can be only one main() method in a program
[D] main() method must be made public

Show Answer

167). What will be the output of the following Java program?
class main_class 
    {
        public static void main(String args[])
        {
            int x = 9;
            if (x == 9) 
            { 
                int x = 8;
                System.out.println(x);
            }
        } 
    }

[A]9
[B]8
[C]Compilation error
[D] Runtime error

Show Answer

168). Which of the following statements is correct?
class main_class 
    {
        public static void main(String args[])
        {
            int x = 9;
            if (x == 9) 
            { 
                int x = 8;
                System.out.println(x);
            }
        } 
    }

[A] Public method is accessible to all other classes in the hierarchy
[B] Public method is accessible only to subclasses of its parent class
[C]Public method can only be called by object of its class
[D]Public method can be accessed by calling object of the public class

Show Answer

169). What will be the output of the following Java program?
    class box 
    {
        int width;
        int height;
        int length;
    } 
    class mainclass 
    {
        public static void main(String args[]) 
        {        
             box obj = new box();
             obj.width = 10;
             obj.height = 2;
             obj.length = 10;
             int y = obj.width * obj.height * obj.length; 
             System.out.print(y);
        } 
    }

[A]12
[B]200
[C]400
[D]100

Show Answer

170). What will be the output of the following Java program?
 class box 
    {
        int width;
        int height;
        int length;
    } 
    class mainclass 
    {
        public static void main(String args[]) 
        {        
            box obj1 = new box();
            box obj2 = new box();
            obj1.height = 1;
            obj1.length = 2;
            obj1.width = 1;
            obj2 = obj1;
            System.out.println(obj2.height);
        } 
    }

[A]1
[B]2
[C]Runtime error
[D] Garbage value

Show Answer

171). What will be the output of the following Java program?
   class box 
   {
        int width;
        int height;
        int length;
   } 
    class mainclass 
    {
        public static void main(String args[]) 
        {        
            box obj = new box();
            System.out.println(obj);
        } 
    }

[A]0
[B]1
[C]Runtime error
[D] classname@hashcode in hexadecimal form

Show Answer