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 5

Which of these keyword must be used to inherit a class?

super
this
extent
extends

SHOW ANSWER

A class member declared protected becomes member of subclass of which type?

public member

private member

protected member
static member

SHOW ANSWER

What is the output of this program?

   
        class A {
        
        int i;
        
        void display() {
        
            System.out.println(i);
        
        }
        
    }
        
    class B extends A {
        
        int j;
        
        void display() {
        
            System.out.println(j);
        
        }
        
    }
        
    class inheritance_demo {
        
        public static void main(String args[])
{
        
            B obj = new B();

                    obj.i=1;

                    obj.j=2;
            
            obj.display();
            
        }
         
   }

0
1
2

Compilation Error

SHOW ANSWER

What is the output of this program?


        final class A {
    
             int i;
    
            }
   
            class B extends A {

                int j;
        
        System.out.println(j + " " + i);
         
    }    
    
        class inheritance {
        
        public static void main(String args[])
{
        
            B obj = new B();
        
            obj.display();
            
        }

            }
 

2 2
3 3
Runtime Error
Compilation Error
SHOW ANSWER

What is the output of this program?

 
        class Abc
  {

              public static void main(String[]args){
        
          String[] elements = { "for", "tea", "too" };
        
          String first = (elements.length > 0) ? elements[0]: null;
        
      }
         
  }

Compilation error
An exception is thrown at run time
The variable first is set to null
The variable first is set to elements[0].
SHOW ANSWER

Which of these class is superclass of every class in Java?
 

String class
Object class
Abstract class
ArrayList class

SHOW ANSWER

Which of these operators can be used to concatenate two or more String objects?

+
+=
&
||

SHOW ANSWER

Which of these constructors is used to create an empty String object?

String()
String(void)
String(0)
None of the mentioned

SHOW ANSWER

Java is developed by?
 

Rasmus Ledorf
James Gosling
Steephen Donald
James Barist

SHOW ANSWER

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

box obj;

Memory address of allocated memory of object

Any arbitrary pointer

NULL

Garbage

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
BACK | NEXT
TRINITY SOFTWARE SOLUTIONS,IInd floor, Radheyam Towers, Gandhari Amman Kovil Road, Pulimood, Trivandrum - 1
0471-2334855 | 2335855 | 9447387064 | 9847003556 info@trinitytechnology.in