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 12

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

Memory address of allocated memory of object

NULL

Any arbitrary pointer

Garbage

SHOW ANSWER

Which of these keywords is used to make a class?

class

struct

int

none of the mentioned

SHOW ANSWER

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

Box obj = new Box();

Box obj = new Box;

obj = new Box();

new Box obj;

SHOW ANSWER

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

malloc

alloc

new

give

SHOW ANSWER

Which of these statement is incorrect?

Every class must contain a main() method

 Applets do not require a main() method at all

There can be only one main() method in a program

main() method must be made public

SHOW ANSWER

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

9

8

Compilation error

Runtime error

SHOW ANSWER

Which of the following statements is correct?

Public method is accessible to all other classes in the hierarchy

Public method is accessible only to subclasses of its parent class

Public method can only be called by object of its class

Public method can be accessed by calling object of the public class

SHOW ANSWER

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

12

200

400

100

SHOW ANSWER

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

2

Runtime error

Garbage value

SHOW ANSWER

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

0

1

Runtime error

classname@hashcode in hexadecimal form

SHOW ANSWER

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

Method overriding

Method overloading

Method doubling

None of the mentioned

SHOW ANSWER

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

finalize

delete

class

constructor

SHOW ANSWER

Which method can be defined only once in a program?

main method

finalize method

static method

private method

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