JAVA Classes and Methods Mcqs

Our collections of Multiple choice questions and answers focuses on study of Java Classes and Methods . These questions are chosen from a collection of most authoritative and best reference books on Java Classes and Methods. Our aim is to prepare an individual for competitive exams like NTS, GAT, ECAT, University and College entrance exams and various tests and job interviews. One should practice our Mcqs to assimilate Java Classes and Methods comprehensively.

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

Function overriding

Function overloading

Function doubling

None of the mentioned

5.
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);        
        } 
     }

0

1

6

25

6.
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());
        } 
    }

False

True

0

1

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

Delete

Free

New

None of the mentioned

11.
What is the output of this program?

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

100

150

200

250

12.
What is the output of this program?

class Compsci
{
     Compsci()throws IOException
     {
 
     } 
 
}
class Bits extends Compsci
{
     Bits()
     {
 
     }
     public static void main(String[]args)
     {
 
     }
}

Compile time error

Run time error

Compile and runs fine

Unreported exception java.io.IOException in default constructor

13.
What is true about private constructor?

Private constructor ensures only one instance of a class exist at any point of time

Private constructor ensures multiple instances of a class exist at any point of time

Private constructor eases the instantiation of a class

Private constructor allows creating objects in other classes

15.
What is false about constructor?

Constructors cannot be synchronized in Java

Java does not provide default copy constructor

Constructor can be overloaded

16.
What is true about Class.getInstance()?

Class.getInstance calls the constructor

Class.getInstance is same as new operator

Class.getInstance needs to have matching constructor

Class.getInstance creates object if class does not have any constructor

0Shares
0
Scroll to Top