Call
whatsapp
9447387064 | 9847003556
0471-2335855 | 8089080088 | 0471-2334855
9447387064 | 9847003556
0471-2335855 | 8089080088 | 0471-2334855
Cisco Training in Trivandrum, Trinity Technologies

No.1 Training Institute in Kerala

JAVA QUESTIONS : PART 13

What is the output of this program?
        class box 
    {
        int width;
        int height;
        int length;
        int volume;
       void volume() 
        {
             volume = width*height*length;
        } 
    }    
    class Output 
    { 
        public static void main(String args[])
        {
            box obj = new box();
            obj.height = 1;
            obj.length = 5;
            obj.width = 5;
            obj.volume();
            System.out.println(obj.volume);        
        } 
    }
 

0

1

25

26

SHOW ANSWER

What is the output of this program?
    class area 
    {
        int width;
        int length;
        int volume;
        area() 
        {
           width=5;
           length=6;
        }
        void volume() 
        {
             volume = width*length*height;
        } 
    }    
    class cons_method 
    {
        public static void main(String args[])
        {
            area obj = new area();
            obj.volume();
            System.out.println(obj.volume);        
        } 
    }

0

1

30

error

SHOW ANSWER

What is the return type of Constructors?

int

float

void

none of the mentioned

SHOW ANSWER

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

import

this

abstract

catch

SHOW ANSWER

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

finalize

delete

constructor

class

SHOW ANSWER

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

SHOW ANSWER

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

SHOW ANSWER

What is the output of this program?
    class area 
    {
        int width;
        int length;
        int area;
        void area(int width, int length) 
        {
            this.width = width;
            this.length = length;
        }
 
    }    
    class Output 
    {
        public static void main(String args[])
        {
            area obj = new area();
            obj.area(5 , 6);
            System.out.println(obj.length + " " + obj.width);        
        } 
    }

 0 0

 5 6

6 5

 5 5

SHOW ANSWER

What is true about constructor?

It can contain return type

It can take any number of parameters

It can have any non access modifiers

Constructor cannot throw an exception

SHOW ANSWER

What would be behaviour if the constructor has a return type?

Compilation error

Runtime error

Compilation and runs successfully

Only String return type is allowed

SHOW ANSWER

Which of the following has the highest memory requirement?

Heap

Stack

JVM

Class

SHOW ANSWER

What is the process of defining two or more methods within same class that have same name but different parameters declaration?

method overloading

method overriding

method hiding

none of the mentioned

SHOW ANSWER

Which of these can be overloaded?

Methods

Constructors

All of the mentioned

None of the mentioned

SHOW ANSWER
BACK | NEXT
TRINITY SOFTWARE SOLUTIONS,IInd floor, Radheyam Towers, Gandhari Amman Kovil Road, Pulimood, Trivandrum - 1
0471-2334855 | 2335855 | 9447387064 | 9847003556 info@trinitytechnology.in