Similar Collections


    No collections found

questions

Title
What is the stored in the object obj in following lines of code

What is the stored in the object obj in following lines of code?

box obj;


  1. Memory address of allocated memory of object
  2. NULL
  3. Any arbitrary pointer
  4. Garbage
discuss
Which of these keywords is used to make a class

Which of these keywords is used to make a class?


  1. class
  2. struct
  3. int
  4. none of the mentioned
discuss
Which of the following is a valid declaration of an object of class Box

Which of the following is a valid declaration of an object of class Box?


  1. Box obj = new Box();
  2. Box obj = new Box;
  3. obj = new Box();
  4. new Box obj;
discuss
Which of these operators is used to allocate memory for an object

Which of these operators is used to allocate memory for an object?


  1. malloc
  2. alloc
  3. new
  4. give
discuss
Which of these statement is incorrect

Which of these statement is incorrect


  1. Every class must contain a main() method
  2. Applets do not require a main() method at all
  3. There can be only one main() method in a program
  4. main() method must be made public
discuss
What is the output of this program

What is the output of this program?

    class main_class 
    {
        public static void main(String args[])
        {
            int x = 9;
            if (x == 9) 
            { 
                int x = 8;
                System.out.println(x);
            }
        } 
    }

  1. 9
  2. 8
  3. Compilation error
  4. Runtime error
discuss
Which of the following statements is correct

Which of the following statements is correct


  1. Public method is accessible to all other classes in the hierarchy
  2. Public method is accessible only to subclasses of its parent class
  3. Public method can only be called by object of its class
  4. Public method can be accessed by calling object of the public class
discuss
What is the output of this program

What is the output of this 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);
        } 
    }

  1. 12
  2. 200
  3. 400
  4. 100
discuss
What is the output of this program

What is the output of this 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);
        } 
    }

  1. 1
  2. 2
  3. Runtime error
  4. Garbage value
discuss
What is the output of this program

What is the output of this 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);
        } 
    }

  1. 0
  2. 1
  3. Runtime error
  4. classname@hashcode in hexadecimal form
discuss
What is the return type of a method that does not return any value

What is the return type of a method that does not return any value?


  1. int
  2. float
  3. void
  4. double
discuss
What is the process of defining more than one method in a class differentiated by method signature

What is the process of defining more than one method in a class differentiated by method signature?


  1. Function overriding
  2. Function overloading
  3. Function doubling
  4. None of the mentioned
discuss
Which of the following is a method having same name as that of it’s class

Which of the following is a method having same name as that of it’s class?


  1. finalize
  2. delete
  3. class
  4. constructor
discuss
Which method can be defined only once in a program

Which method can be defined only once in a program?


  1. main method
  2. finalize method
  3. static method
  4. private method
discuss
What is the output of this program

What is the output of this program?

    class box 
    {
        int width;
        int height;
        int length;
        int volume;
        void volume(int height, int length, int width) 
        {
             volume = width*height*length;
        } 
    }    
    class Prameterized_method
    {
        public static void main(String args[])
        {
            box obj = new box();
            obj.height = 1;
            obj.length = 5;
            obj.width = 5;
            obj.volume(3,2,1);
            System.out.println(obj.volume);        
        } 
     }

  1. 0
  2. 1
  3. 6
  4. 25
discuss
What is the output of this program

What is the output of this program?

   class equality 
    {
        int x;
        int y;
        boolean isequal()
        {
            return(x == y);  
        } 
    }    
    class Output 
    {
        public static void main(String args[])
        {
            equality obj = new equality();
            obj.x = 5;
            obj.y = 5;
            System.out.println(obj.isequal());
        } 
    }

  1. false
  2. True
  3. 0
  4. 1
discuss
Which keyword is used by the method to refer to the object that invoked it

Which keyword is used by the method to refer to the object that invoked it?


  1. import
  2. catch
  3. abstract
  4. this
discuss
Which of the following is a method having same name as that of its class

Which of the following is a method having same name as that of its class?


  1. finalize
  2. delete
  3. class
  4. constructor
discuss
Which operator is used by Java run time implementations to free the memory of an object when it is no longer needed

Which operator is used by Java run time implementations to free the memory of an object when it is no longer needed?


  1. delete
  2. free
  3. new
  4. none of the mentioned
discuss
Which function is used to perform some action when the object is to be destroyed

Which function is used to  perform some action when the object is to be destroyed?


  1. finalize()
  2. delete()
  3. main()
  4. none of the mentioned
discuss
total MCQs: 295

MCQs

295

Views

287

Best Answers

299

Points

5