Java Basics
Java OOPs
Java Array
MISC
Control statements
100

Which of the following is not java keyword?

1. static

2. try

3. Integer

4. new


Integer

100

Inheritance is object oriented principle ..

true

Or 

false


true

100

Which of these operators is used to allocate memory to array variable in Java?
a) malloc
b) alloc
c) new
d) new malloc

c) new

100

Which of these operators can be used to concatenate two or more String objects?
a) +
b) +=
c) &
d) ||

a)+

100

The while loop repeats a set of code while the condition is not met?
a) True
b) False

a) True

200

Choose the appropriate data type for this value: 5.5

1. double

2. String

3. Integer

double

200

Which concept of Java is achieved by combining methods and attribute into a class?
a) Encapsulation
b) Inheritance
c) Polymorphism
d) Abstraction

Encapsulation

200

Which of these is an incorrect array declaration?
a) int arr[] = new int[5]
b) int [] arr = new int[5]
c) int arr[] = new int[5]
d) int arr[] = int [5] new

d) int arr[] = int [5] new

200

Which of this method of class String is used to obtain a length of String object?
a) get()
b) Sizeof()
c) lengthof()
d) length()

d) length()

200

What is true about a break?
a) Break stops the execution of entire program
b) Break halts the execution and forces the control out of the loop
c) Break forces the control out of the loop and starts the execution of next iteration
d) Break halts the execution of the loop for certain time frame

b) Break halts the execution and forces the control out of the loop

300

An Object could be...

1. algorithm

2. program

3. class

4. Anything  

Anything

300

Method overriding is combination of inheritance and polymorphism?
a) True
b) false

True

300

 What will be the output of the following Java code?

    int arr[] = new int [5];    

    System.out.print(arr);

a) 0
b) value stored in arr[0]
c) 00000
d) Class name@ hashcode in hexadecimal form

d) Class name@ hashcode in hexadecimal form

300

What does DRY stand for in coding?

Don't Repeat Yourself

300

Which of the following is not a valid jump statement?
a) break
b) goto
c) continue
d) return

d) return

400

What is the default value of String variable?

A - ""

B - ''

C - null

D - not define

null

400

When Overloading does not occur?
a) More than one method with same name but different method signature and different number or type of parameters
b) More than one method with same name, same signature but different number of signature
c) More than one method with same name, same signature, same number of parameters but different type
d) More than one method with same name, same number of parameters and type but different signature

D) More than one method with same name, same number of parameters and type but different signature

400

Which of these is necessary to specify at time of array initialization?
a) Row
b) Column
c) Both Row and Column
d) None of the mentioned

a) Row

400

Name 4 of the 8 Primitive Data Types in Java

char, int, double, boolean, float, short, long, byte

400

What will be the output of the following Java program?

    class comma_operator 

   {

        public static void main(String args[]) 

        {    

           int sum = 0;

        for (int i = 0, j = 0; i < 5 & j < 5; ++i, j = i+1)          sum += i;

        System.out.println(sum);

      } 

    }

a) 5
b) 6
c) 14
d) compilation error

b) 6

500

What is instance variable?

A - Instance variables are static variables within a class but outside any method.

B - Instance variables are variables defined inside methods, constructors or blocks.

C - Instance variables are variables within a class but outside any method.

D - None of the above.

Instance variables are variables within a class but outside any method.

500

What is the first method to run when you instantiate a class in Java?
a) Getter
b) Setter
c) Constructor
d) Deconstructor

c) Constructor

500

What will be the output of the following Java code?

  class array_output 

 {

     public static void main(String args[]) 

    {   int array_variable [] = new int[10];

         for (int i = 0; i < 10; ++i) 

          {  array_variable[i] = i;

             System.out.print(array_variable[i] + " ");

              i++;

           }

     }

  }

a) 0 2 4 6 8
b) 1 3 5 7 9
c) 0 1 2 3 4 5 6 7 8 9
d) 1 2 3 4 5 6 7 8 9 10

a) 0 2 4 6 8

500

What will be the output of the following Java program?

    class String_demo 

    {

        public static void main(String args[])

        {

            char chars[] = {'a', 'b', 'c'};

            String s = new String(chars);

            System.out.println(s);

        }

   }

a) a
b) b
c) c
d) abc

d) abc

500

What is the valid data type for variable “a” to print “Hello World”?

switch(a)

{

   System.out.println("Hello World");

}

a) int and float
b) byte and short
c) char and long
d) byte and char

d) byte and char