Google News
logo
Java - Quiz(MCQ)
1 .
Who is inventor of Java ?
A)
James Gosling
B)
Mark Jukervich
C)
Dennis Ritchie
D)
Steve Jobs

Correct Answer :  

James Gosling

2 .
Java initial release date ?
A)
1961
B)
1979
C)
1982
D)
1991

Correct Answer :   1991

3 .
Which tool is required on each machine to run a Java program?
A)
JDK
B)
JRE
C)
SDK
D)
CVS

Correct Answer :  

JRE

4 .
Choose the appropriate data type for this value: "volatile"    
A)
Int
B)
Boolean
C)
String 
D)
Double

Correct Answer :  

String 

5 .
Which one needs a web page to run
A)
A Java Class
B)
A Java Application
C)
A Java Stand-Alone Application
D)
A Java Applet 

Correct Answer :  

A Java Applet 

6 .
What is a loop ?
A)
A segment of code to be run infinite times
B)
A segment of code to be run a specified amount of times
C)
A segment of code to be run once
D)
A new type of Applet.

Correct Answer :  

A segment of code to be run a specified amount of times 

7 .
Which of the following are Java keywords?
A)
throw
B)
void
C)
private
D)
All of the above.

Correct Answer :  

All of the above.

8 .
Which of the following is not a Java keyword?
A)
Main 
B)
Integer
C)
Try 
D)
String  

Correct Answer :  

Integer 

9 .
Which of the following are primitive types ?
A)
String
B)
Float
C)
integer
D)
byte

Correct Answer :  

byte

10 .
What is the keyword used in java to create an object?
A)
New 
B)
New()
C)
Sync
D)
This

Correct Answer :  

New

11 .
Choose the appropriate data type for this value: "1"  
A)
Int
B)
Char 
C)
Boolean 
D)
String

Correct Answer :  

String

12 .
What does GUI stand for?
A)
Graphical User Interface
B)
Grand User Interface
C)
Graphical Useful Interface
D)
Gaming User Interface

Correct Answer :  

Graphical User Interface 

13 .
What does AWT stands for ?
A)
Adjust Window Toolkit
B)
Abstract window Toolkit
C)
Advanced Window Toolkit
D)
None of the choices

Correct Answer :   Abstract window Toolkit

14 .
Which of the following is the highest class in the event-delegation model ?
A)
java.awt.AWTEvent
B)
java.util.EventListener
C)
java.util.EventObject 
D)
None of the above

Correct Answer :  

java.util.EventObject 

15 .
Which declaration of the main method below would allow a class to be started as a standalone program.
A)
public static int main(char args[])
B)
public static void main(String args[]) 
C)
public static void main(String args)
D)
public static void MAIN(String args[])

Correct Answer :  

public static void main(String args[])

16 .
Method,Field can be accessed from the same class to which they belong.
A)
Public
B)
Private 
C)
Protected
D)
Default

Correct Answer :  

Private 

17 .
An object could be ...
A)
An algorithm
B)
A program
C)
A data container
D)
Anything

Correct Answer :  

Anything

18 .
What is the meaning of the return data type void?
A)
An empty memory space is returned so that the developers can utilize it.
B)
void is not supported in Java .
C)
void returns no data type.
D)
None of the above

Correct Answer :  

void returns no data type. 

19 .
What are/is the part/parts in executing a Java program ?
A)
Java Compiler
B)
Java Interpreter
C)
Both of the above 
D)
None of the above

Correct Answer :  

Both of the above

20 .
Which of these are legal identifiers.
A)
number_1
B)
number_a
C)
$1234
D)
All of the above.

Correct Answer :  

All of the above.

21 .
Which of these are legal array declarations or definitions?
A)
int[] []x[];
B)
int x[5];
C)
int *x;
D)
None of the above

Correct Answer :  

int[] []x[];

22 .
What is printed by code below?
 
String[] array = {"1","2","4","5"};
int i = array.length;
for(String x : array)i++;
System.out.println(i);
A)
12
B)
8
C)
5
D)
4

Correct Answer :   8

23 .
The last value in an array called ar can be found at index:
A)
B)
1
C)
Ar.length
D)
Ar.length - 1

Correct Answer :  

Ar.length - 1

24 .
A class is...
A)
An object
B)
An abstract definition of an object 
C)
An executable piece of code
D)
A varibale

Correct Answer :  

An abstract definition of an object

25 .
In java, float takes _________ bytes in memory.
A)
2
B)
4
C)
6
D)
8

Correct Answer :  

4

26 .
What is the size of long variable?
A)
8 bit
B)
16 bit
C)
32 bit
D)
64 bit

Correct Answer :  

64 bit

27 .
What will be printed?
String s1 = "a";
String s2 = s1;
s1 += "b";
System.out.println(s2);​
A)
B)
b
C)
ab
D)
ba

Correct Answer :  

a

28 .
What are the functions of the dot(.) operator ?
A)
It enables you to store values in instance variables of an object
B)
It enables you to access instance variables of any objects within a class
C)
It is used to call object methods
D)
All of the above

Correct Answer :  

All of the above

29 .
The most common use of an array is to:
A)
Perform for loop on array
B)
Perform different operations on each element in array
C)
Perform the same operation on all elements in array
D)
Perform while loop on array

Correct Answer :  

Perform the same operation on all elements in array

30 .
How to sort an array?
A)
Array.sort()
B)
Arrays.sort()
C)
Collection.sort()
D)
System.sort()

Correct Answer :  

Arrays.sort()

31 .
Which of the following is correct constructor for thread?
A)
Thread(Runnable a, String str)
B)
Thread(int priority)
C)
Thread(Runnable a, int priority)
D)
Thread(Runnable a, ThreadGroup t)

Correct Answer :  

Thread(Runnable a, String str)

32 .
Which method of the Runnable interface that must be implemented by all threads?
A)
Run()
B)
Start()
C)
Sleep()
D)
Wait()

Correct Answer :  

Run() 

33 .
Java allows which type of inheritance
A)
single-inheritance
B)
multiple-inheritance through interfaces
C)
multi-level inheritance
D)
All of the above

Correct Answer :  

All of the above

34 .
What is an instanceof?
A)
A keyword only
B)
An operator only
C)
A methods in object
D)
An operator and keyword

Correct Answer :  

An operator and keyword

35 .
Which one could be used as the main container in a Java application?
A)
JPanel 
B)
JButton 
C)
JFrame
D)
JApplet

Correct Answer :  

JFrame

36 .
What about constructor?
A)
It can contain return type
B)
It can take any number of parameters 
C)
It can have any non access modifiers
D)
Constructor cannot throw exception

Correct Answer :  

It can take any number of parameters

37 .
From the following what are the OOPs principles in JAVA?
A)
Polymorphism
B)
Inheritance
C)
Encapsulation
D)
All of the above

Correct Answer :  

All of the above

38 .
What is polymorphism?
A)
Polymorphism is a technique to define different objects of same type.
B)
Polymorphism is the ability of an object to take on many forms. 
C)
Polymorphism is a technique to define different methods of same type.
D)
None of the above.

Correct Answer :  

Polymorphism is the ability of an object to take on many forms.

39 .
Which variables can an inner class access from the class which encapsulates it ?
A)
All final variables
B)
All instance variables
C)
All static variables
D)
All of the above

Correct Answer :  

All of the above

40 .
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.

Correct Answer :  

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

41 .
Which one is a valid declaration of a boolean?
A)
boolean b1 = 1;
B)
boolean b2 = ‘false’;
C)
boolean b3 = false;
D)
boolean b4 = ‘true’

Correct Answer :  

boolean b3 = false;

42 .
What class must an inner class extend ?
A)
Any class or interface 
B)
The Object class 
C)
It must extend an interface
D)
The top level class

Correct Answer :  

Any class or interface

43 .
Every class in Java is a sub-class of what?
A)
String Class
B)
Java Class
C)
Object Class
D)
All of the above

Correct Answer :  

Object Class

44 .
With inheritance, a derived subclass object can directly access any
A)
Public or private superclass member
B)
Public superclass member (and protected subclass members if it's in the same package) 
C)
Protected, public or private superclass member
D)
Private superclass member

Correct Answer :  

Public superclass member (and protected subclass members if it's in the same package) 

45 .
What's the difference between an Applet and an application ?
A)
Applets are run over the web.
B)
Applets can paint words, applications cannot. 
C)
An application is only available on Windows
D)
None of the above.

Correct Answer :  

Applets are run over the web. 

46 .
What is the role of the constructor? 
A)
To create some type of change in the state of an object
B)
Create an instance of a class (an object)
C)
Create names for methods
D)
None of the above

Correct Answer :  

Create an instance of a class (an object) 

47 .
The size of a frame is set using ...
A)
WIDTH and HEIGHT properties of the window menu in Eclipse
B)
The width and height attributes of the class JFrame
C)
The method setSize() 
D)
Automtically in run-time

Correct Answer :  

The method setSize() 

48 .
Base class for all exceptions
A)
Java.Lang.Exception
B)
Java.throwable
C)
Java.Lang.throwables
D)
Java.Lang.throwable

Correct Answer :  

Java.Lang.throwable

49 .
Environment variable that stores the location of bin folder
A)
BIN
B)
PATH
C)
PATHS 
D)
CLASSPATHS

Correct Answer :  

PATH 

50 .
What will be printed?
double value = 2 / 3;
System.out.println(value);
A)
0.0
B)
0.6666666666666666
C)
1
D)
1.0

Correct Answer :  

0.0

51 .
Object-Oriented Programming means ...  
A)
Writing an algorithm before writing your program and having a test plan 
B)
Writing a program composed of Java classes
C)
Designing the application based on the objects discovered when analysing the problem
D)
Being objective about what you develop

Correct Answer :  

Writing an algorithm before writing your program and having a test plan 

52 .
What is an Applet ?
A)
A Java program that does not run through a web browser 
B)
A Java program that is run through a web browser 
C)
An object-oriented programming language 
D)
An interactive website

Correct Answer :  

A Java program that is run through a web browser

53 .
Which statement is true for method overloading?
A)
The overloaded method must be declared in the parent class
B)
Multiple methods in same class, same name and return type, different parameters
C)
Method name, return type and paramters must be all same
D)
Methods in parent class are same name and types, but behavior is different in child class

Correct Answer :  

Multiple methods in same class, same name and return type, different parameters

54 .
What is the main function of any variable ?
A)
To add numbers together
B)
To write Java codes
C)
To keep track of data in the memory of the computer 
D)
To print words on the screen

Correct Answer :  

To keep track of data in the memory of the computer 

55 .
What is the replacement of joda time library in java 8?
A)
java.date (JSR-310)
B)
java.time (JSR-310) 
C)
java.joda
D)
java.jodaTime

Correct Answer :  

java.time (JSR-310)

56 .
What will be printed?
int i = 255;
byte b = (byte) i;
System.out.println(b);
A)
255
B)
-255
C)
NaN
D)
-1

Correct Answer :  

-1

57 .
How is Date stored in database?
A)
java.sql.Date 
B)
java.util.Date
C)
java.sql.DateTime
D)
java.util.DateTime

Correct Answer :  

java.sql.Date

58 .
What is the output of this program?
class average {
        public static void main(String args[])
        {
            double num[] = {5.5, 10.1, 11, 12.8, 56.9, 2.5};
            double result;
            result = 0;
            for (int i = 0; i < 6; ++i) 
                result = result + num[i];
	    System.out.print(result/6);
 
        } 
    }​
A)
16.34
B)
16.566666644
C)
16.46666666666667 
D)
16.46666666666666

Correct Answer :  

16.46666666666667

59 .
What will be the output of the program?
class Bitwise 
{
    public static void main(String [] args) 
    {
        int x = 11 & 9;
        int y = x ^ 3;
        System.out.println( y | 12 );
    }
}​
A)
0
B)
7
C)
8
D)
14

Correct Answer :  

14 

60 .
Which class can access all public and protected methods and fields of its super class?
A)
Inner class
B)
outer class
C)
sub-class
D)
None of the above

Correct Answer :  

sub-class 

61 .
What will be printed
int a = -1;
a = a >> 1;
System.out.println(a);​
A)
-1
B)
0
C)
D)
2147483647

Correct Answer :  

-1

62 .
What will be the output of following piece of code? ? 
public class operatorExample { 
    public static void main(String args[]) { 
    int x=4; System.out.println(x++);
    }
 }
​
A)
output=0
B)
output=6
C)
 output=5
D)
output=4

Correct Answer :  

output=4 

63 .
What will be the output of Round(3.7).
A)
4
B)
3.7
C)
3
D)
4.5

Correct Answer :  

4

64 .
Which Keyword is used If a class has multiple constructors defined,it's possible to call a constructor from another constructor’s body?
A)
super()
B)
constant()
C)
this()
D)
None of the above

Correct Answer :  

this()

65 .
What will be printed?
byte b = (byte) 128;
b >>>= 1;
System.out.println(b);​
A)
-64 
B)
-128
C)
64
D)
128

Correct Answer :  

-64

66 .
What will be printed?
int a = 1;
a += ++a * a;
System.out.println(a);​
A)
2
B)
4
C)
5
D)
6

Correct Answer :  

67 .
Which of the following is true?
public final class Main {

  static final String s = "hello";

  public void main(String[] args) {
    System.out.println(s);
  }

}
A)
The code will print "hello"
B)
The code will fail at run time  
C)
The code won't compile
D)
None of the above

Correct Answer :  

The code will fail at run time

68 .
Which of these statements is true about both Abstract Classes and Interfaces?
A)
In both methods can only be declared but can not have a definition
B)
Abstract Classes can only have declared methods, Interfaces can have definitions
C)
The same keyword is used for both Abstract Classes and Interfaces
D)
Abstract classes can define methods but Interfaces can only delcare methods

Correct Answer :  

Abstract classes can define methods but Interfaces can only delcare methods           -(D)

69 .
What is the output of the following code?
String x = "John Doe";
System.out.println("'"+x.substring(5)+"'");
A)
 'John'
B)
' Doe'
C)
'Doe' 
D)
None of the above

Correct Answer :   'Doe' 

70 .
What gets printed?
String a = "Hello";
String b = " Hello ";
System.out.println(a.equals(b));
A)
1
B)
0
C)
true
D)
false

Correct Answer :  

false

71 .
Which will legally declare, construct, and initialize an array?
A)
int [] myList = {"1", "2", "3"};
B)
int [] myList = (5, 8, 2);
C)
int myList [] [] = {4,9,7,0};
D)
int myList [] = {4, 3, 7};

Correct Answer :   int myList [] = {4, 3, 7};

72 .
Which is a reserved word in the Java programming language?
A)
method
B)
native
C)
subclasses
D)
reference

Correct Answer :   native

73 .
Which is a valid keyword in java?
A)
interface
B)
string
C)
Float
D)
unsigned

Correct Answer :   interface

74 .
Which is the valid declarations within an interface definition?
A)
public double methoda();
B)
public final double methoda();
C)
static void methoda(double d1);
D)
protected void methoda(double d1);

Correct Answer :   public double methoda();

75 .
What is the range of short data type in Java?
A)
-128 to 127
B)
-32768 to 32767
C)
-2147483648 to 2147483647
D)
None of the above

Correct Answer :   -32768 to 32767

76 .
Which of the following are legal lines of Java code?
 
   1. int w = (int)888.8;
   2. byte x = (byte)100L;
   3. long y = (byte)100;
   4. byte z = (byte)100L;
A)
1 and 2
B)
2 and 3
C)
3 and 4
D)
All statements are correct

Correct Answer :   All statements are correct

77 .
Which of these literals can be contained in float data type variable?
A)
-1.7e+308
B)
3.4e+038
C)
+1.7e+308
D)
-3.4e+050

Correct Answer :   3.4e+038

78 .
Which data type value is returned by all transcendental math functions?
A)
int
B)
float
C)
double
D)
long

Correct Answer :   double

79 .
What will be the output of the following Java code?
 
    class increment {
        public static void main(String args[]) 
        {        
             int g = 3;
             System.out.print(++g * 8);
        } 
    }
A)
24
B)
25
C)
32
D)
33

Correct Answer :   32

80 .
What is the order of variables in Enum?
A)
Random order
B)
Descending order
C)
Depends on the order() method
D)
Ascending order

Correct Answer :   Ascending order

81 .
If we try to add Enum constants to a TreeSet, what sorting order will it use?
A)
Sorted in the order of declaration of Enums
B)
Sorted in alphabetical order of Enums
C)
Sorted based on order() method
D)
Sorted in descending order of names of Enums

Correct Answer :   Sorted in the order of declaration of Enums

82 .
What will be the output of the following Java code snippet?
 
 enum Levels 
{
    private TOP,
 
    public MEDIUM,
 
    protected BOTTOM;
}
A)
Runtime Error
B)
Compilation Error
C)
It runs successfully
D)
EnumNotDefined Exception

Correct Answer :   Compilation Error

83 .
Which method returns the elements of Enum class?
A)
getEnums()
B)
getEnum()
C)
getEnumConstants()
D)
getEnumList()

Correct Answer :  

84 .
Which of the following is the advantage of BigDecimal over double?
A)
Syntax
B)
Memory usage
C)
Garbage creation
D)
Precision

Correct Answer :   Precision

85 .
What is the limitation of toString() method of BigDecimal?
A)
There is no limitation
B)
toString returns null
C)
toString uses scientific notation
D)
toString returns the number in expanded form

Correct Answer :   toString uses scientific notation

86 .
What is BigDecimal.ONE?
A)
custom defined statement
B)
static variable with value 1 on scale 0
C)
static variable with value 1 on scale 10
D)
wrong statement

Correct Answer :   static variable with value 1 on scale 0

87 .
Which of these can be returned by the operator &?
A)
Integer
B)
Boolean
C)
Character
D)
Integer or Boolean

Correct Answer :   Integer or Boolean

88 .
Which of these can not be used for a variable name in Java?
A)
identifier
B)
keyword
C)
identifier & keyword
D)
None of the above

Correct Answer :   keyword

89 .
What will be the output of the following Java program?
 
    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/2;
                array_variable[i]++;
                System.out.print(array_variable[i] + " ");
                i++;
            }
 
        } 
    }
A)
0 2 4 6 8
B)
1 2 3 4 5
C)
0 1 2 3 4 5 6 7 8 9
D)
1 2 3 4 5 6 7 8 9 10

Correct Answer :   1 2 3 4 5

90 .
What will be the output of the following Java program?
 
    class dynamic_initialization 
    {
        public static void main(String args[]) 
        {
            double a, b;
            a = 3.0;
            b = 4.0;
	    double c = Math.sqrt(a * a + b * b);
	    System.out.println(c);
        } 
    }
A)
5.0
B)
7.0
C)
25.0
D)
Compilation Error

Correct Answer :   5.0

91 .
Which of these is necessary condition for automatic type conversion in Java?
A)
The destination type is smaller than source type
B)
The destination type is larger than source type
C)
The destination type can be larger or smaller than source type
D)
None of the mentioned

Correct Answer :   The destination type is larger than source type

92 .
What is the prototype of the default constructor of this Java class?
public class prototype { }​
A)
prototype( )
B)
prototype(void)
C)
public prototype( )
D)
public prototype(void)

Correct Answer :   public prototype( )

93 .
What is Truncation is Java?
A)
Floating-point value assigned to an integer type
B)
Integer value assigned to floating type
C)
Floating-point value assigned to an Floating type
D)
Integer value assigned to floating type

Correct Answer :   Floating-point value assigned to an integer type

94 .
What will be the output of the following Java code?
 
    class conversion 
    {
        public static void main(String args[]) 
        {
            double a = 295.04;
            int  b = 300;
            byte c = (byte) a;
            byte d = (byte) b;
            System.out.println(c + " "  + d);
        } 
    }
A)
38 43
B)
39 44
C)
295 300
D)
295.04 300

Correct Answer :   39 44

95 .
What will be the output of the following Java program, if we run as “java main_arguments 1 2 3”?
 
    class main_arguments 
    {
        public static void main(String [] args) 
        {
            String [][] argument = new String[2][2];
            int x;
            argument[0] = args;
            x = argument[0].length;
            for (int y = 0; y < x; y++) 
                System.out.print(" " + argument[0][y]);              
        }
    }
A)
1 0
B)
1 1
C)
1 0 3
D)
1 2 3

Correct Answer :   1 2 3

96 .
What will be the output of the following Java program?
 
    class c 
    {    
        public void main( String[] args ) 
        {  
            System.out.println( "Hello" + args[0] ); 
        } 
    }
A)
Hello
B)
Hello c
C)
Hello world
D)
Runtime Error

Correct Answer :   Runtime Error

97 .
What is the type of variable ‘b’ and ‘d’ in the following Java snippet?
 
int a[], b;
int []c, d;
A)
‘b’ and ‘d’ are int
B)
‘b’ and ‘d’ are arrays of type int
C)
‘b’ is int variable; ‘d’ is int array
D)
‘d’ is int variable; ‘b’ is int array

Correct Answer :   ‘b’ is int variable; ‘d’ is int array

98 .
What will be the output of the following Java code?
 
int arr[] = new int [5];
System.out.print(arr);
A)
0
B)
00000
C)
value stored in arr[0].
D)
Garbage value

Correct Answer :   Garbage value

99 .
What will be the output of the following Java code snippet?
 
Object[] names = new String[3];
names[0] = new Integer(0);
A)
ArrayStoreException
B)
Code runs successfully
C)
ArrayIndexOutOfBoundsException
D)
Compilation Error

Correct Answer :   ArrayStoreException

100 .
How to copy contents of array?
A)
System.arrayCopy()
B)
Array.copy()
C)
Arrays.copy()
D)
Collection.copy()

Correct Answer :   System.arrayCopy()

101 .
An array elements are always stored in ________ memory locations.
A)
Random
B)
Sequential
C)
Binary search
D)
Sequential and Random

Correct Answer :   Sequential

102 .
Modulus operator, %, can be applied to which of these?
A)
Integers
B)
Floating – point numbers
C)
Both Integers and floating – point numbers
D)
None of the above

Correct Answer :   Both Integers and floating – point numbers

103 .
With x = 0, which of the following are legal lines of Java code for changing the value of x to 1?
 
   1. x++;
   2. x = x + 1;
   3. x += 1;
   4. x =+ 1;
A)
1, 2, 3 & 4
B)
1, 2 & 3
C)
1 & 4
D)
3 & 2

Correct Answer :   1, 2, 3 & 4

104 .
What will be the output of the following Java program?
 
    class increment 
    {
        public static void main(String args[])
        {
            double var1 = 1 + 5; 
            double var2 = var1 / 4;
            int var3 = 1 + 5;
            int var4 = var3 / 4;
            System.out.print(var2 + " " + var4);
 
        } 
    }
A)
0 1
B)
1 1
C)
1.5 1
D)
1.5 1.0

Correct Answer :   1.5 1

105 .
What will be the output of the following Java program?
 
    class Modulus 
    {
        public static void main(String args[]) 
        {    
             double a = 25.64;
             int  b = 25;
             a = a % 10;
             b = b % 10;
             System.out.println(a + " "  + b);
        } 
    }
A)
5 5
B)
5.640000000000001 5
C)
5.640000000000001 5.0
D)
5 5.640000000000001

Correct Answer :   5.640000000000001 5

106 .
Which of these is not a bitwise operator?
A)
&
B)
&=
C)
|=
D)
<=

Correct Answer :   <=

107 .
Which of these statements are incorrect?
A)
The right shift operator automatically fills the higher order bits with 0
B)
The left shift operator can be used as an alternative to multiplying by 2
C)
The right shift operator, >>, shifts all of the bits in a value to the right specified number of times
D)
The left shift operator, <<, shifts all of the bits in a value to the left specified number of times

Correct Answer :   The right shift operator automatically fills the higher order bits with 0

108 .
What will be the output of the following Java program?
 
    class bitwise_operator 
    {
        public static void main(String args[]) 
        {    
             int a = 3;
             int b = 6;
 	     int c = a | b;
             int d = a & b;             
             System.out.println(c + " "  + d);
        } 
    }
A)
5 2
B)
7 2
C)
7 5
D)
7 7

Correct Answer :   7 2

109 .
What will be the output of the following Java program?
 
    class Output 
    {
        public static void main(String args[]) 
        {    
             int a = 1;
             int b = 2;
             int c = 3;
             a |= 4;
             b >>= 1;
             c <<= 1;
             a ^= c;
             System.out.println(a + " " + b + " " + c);
        } 
    }
A)
2 2 3
B)
2 3 4
C)
3 1 6
D)
3 3 6

Correct Answer :   3 1 6

110 .
Which of these is returned by “greater than”, “less than” and “equal to” operators?
A)
Integers
B)
Boolean
C)
Floating – point numbers
D)
None of the above

Correct Answer :   Boolean

111 .
What will be the output of the following Java code?
 
    class Relational_operator 
    {
        public static void main(String args[])
        {
            int var1 = 5; 
            int var2 = 6;
            System.out.print(var1 > var2);
        } 
    }
A)
0
B)
1
C)
True
D)
False

Correct Answer :   False

112 .
What will be the output of the following Java code?
 
    class bool_operator 
    {
        public static void main(String args[]) 
        {    
             boolean a = true;
             boolean b = !true;
             boolean c = a | b;
 	     boolean d = a & b;
             boolean e = d ? b : c;
             System.out.println(d + " " + e);
        } 
    }
A)
false false
B)
false true
C)
true false
D)
true ture

Correct Answer :   false true

113 .
What will be the output of the following Java code?
 
    class Output 
    {
        public static void main(String args[]) 
        {    
             int x , y = 1;
             x = 10;
             if (x != 10 && x / 0 == 0)
                 System.out.println(y);
             else
                 System.out.println(++y);
        } 
    }
A)
1
B)
2
C)
Unpredictable behavior of program
D)
Runtime error owing to division by zero in if condition

Correct Answer :   2

114 .
What should be expression1 evaluate to in using ternary operator as in this line?
 
 expression1 ?  expression2  :  expression3
A)
Integer
B)
Boolean
C)
Floating – point numbers
D)
None of the above

Correct Answer :   Boolean

115 .
What is the value stored in x in the following lines of Java code?
 
   int x, y, z;
    x = 0;
    y = 1;
    x = y = z = 8;
A)
0
B)
1
C)
8
D)
9

Correct Answer :   8

116 .
What will be the output of the following Java code?
 
    class operators 
    {
        public static void main(String args[]) 
        {    
             int x = 8;
             System.out.println(++x * 3 + " " + x);
        } 
    }
A)
24 8
B)
24 9
C)
27 8
D)
27 9

Correct Answer :   27 9

117 .
Which of these selection statements test only for equality?
A)
if
B)
switch
C)
if & switch
D)
None of the above

Correct Answer :   switch

118 .
Which of these jump statements can skip processing the remainder of the code in its body for a particular iteration?
A)
break
B)
return
C)
continue
D)
exit

Correct Answer :   continue

119 .
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

Correct Answer :   6

120 .
What will be the output of the following Java program?
 
class Output 
{
        public static void main(String args[]) 
        {    
           final int a=10,b=20;
          while(a<b)
          {
 
          System.out.println("Hello");
          }
          System.out.println("World");
 
        } 
}
A)
Hello
B)
Hello world
C)
run time error
D)
compile time error

Correct Answer :   compile time error

121 .
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 halts the execution of the loop for certain time frame
D)
Break forces the control out of the loop and starts the execution of next iteration

Correct Answer :   Break halts the execution and forces the control out of the loop

122 .
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

Correct Answer :   byte and char

123 .
From where break statement causes an exit?
A)
Terminates a program
B)
Only from innermost loop
C)
From innermost loops or switches
D)
Only from innermost switch

Correct Answer :   From innermost loops or switches

124 .
Which of the following is not OOPS concept in Java?
A)
Inheritance
B)
Encapsulation
C)
Polymorphism
D)
Compilation

Correct Answer :   Compilation

125 .
Which of the following is a type of polymorphism in Java?
A)
Compile time polymorphism
B)
Multiple polymorphism
C)
Multilevel polymorphism
D)
Execution time polymorphism

Correct Answer :   Compile time polymorphism

126 .
Which concept of Java is a way of converting real world objects in terms of class?
A)
Polymorphism
B)
Encapsulation
C)
Abstraction
D)
Inheritance

Correct Answer :   Abstraction

127 .
What is it called where object has its own lifecycle and child object cannot belong to another parent object?
A)
Aggregation
B)
Composition
C)
Encapsulation
D)
Association

Correct Answer :   Aggregation

128 .
Which component is used to compile, debug and execute java program?
A)
JVM
B)
JDK
C)
JRE
D)
JIT

Correct Answer :   JDK

129 .
Which component is responsible to run java program?
A)
JVM
B)
JDK
C)
JIT
D)
JRE

Correct Answer :   JRE

130 .
What is the extension of compiled java classes?
A)
.class
B)
.java
C)
.txt
D)
.js

Correct Answer :   .class

131 .
How can we identify whether a compilation unit is class or interface from a .class file?
A)
Java source file header
B)
Extension of compilation unit
C)
We cannot differentiate between class and interface
D)
The class or interface name should be postfixed with unit type

Correct Answer :   Java source file header

132 .
What is use of interpreter?
A)
It is a synonym for JIT
B)
They are intermediated between JIT and JVM
C)
They read high level code and execute them
D)
They convert bytecode to machine language code

Correct Answer :   They read high level code and execute them

133 .
What is the stored in the object obj in following lines of Java code?
 
   box obj;
A)
NULL
B)
Garbage
C)
Any arbitrary pointer
D)
Memory address of allocated memory of object

Correct Answer :   NULL

134 .
Which of the following is a valid declaration of an object of class Box?
A)
Box obj = new Box();
B)
Box obj = new Box;
C)
obj = new Box();
D)
new Box obj;

Correct Answer :   Box obj = new Box();

135 .
What will be the output of the following Java program?
 
    class main_class 
    {
        public static void main(String args[])
        {
            int x = 9;
            if (x == 9) 
            { 
                int x = 8;
                System.out.println(x);
            }
        } 
    }
A)
8
B)
9
C)
Runtime error
D)
Compilation error

Correct Answer :   Compilation error

136 .
Which keyword is used by the method to refer to the object that invoked it?
A)
import
B)
abstract
C)
catch
D)
this

Correct Answer :   this

137 .
Which function is used to perform some action when the object is to be destroyed?
A)
finalize()
B)
delete()
C)
main()
D)
None of the above

Correct Answer :   finalize()

138 .
What will be the output of the following Java code?
 
    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);
        }
   }
A)
100
B)
150
C)
200
D)
250

Correct Answer :   150

139 .
What would be the behaviour if this() and super() used in a method?
A)
Runtime error
B)
Runs successfully
C)
compile time error
D)
Throws exception

Correct Answer :   compile time error

140 .
What is true about Class.getInstance()?
A)
Class.getInstance calls the constructor
B)
Class.getInstance is same as new operator
C)
Class.getInstance needs to have matching constructor
D)
Class.getInstance creates object if class does not have any constructor

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

141 .
What is not the use of “this” keyword in Java?
A)
Passing itself to another method
B)
Calling another constructor in constructor chaining
C)
Passing itself to method of the same class
D)
Referring to the instance variable when local variable has the same name

Correct Answer :   Passing itself to method of the same class

142 .
What would be behaviour if the constructor has a return type?
A)
Compilation error
B)
Runtime error
C)
Compilation and runs successfully
D)
Only String return type is allowed

Correct Answer :   Compilation error

143 .
What is the process of defining two or more methods within same class that have same name but different parameters declaration?
A)
method overriding
B)
method overloading
C)
method hiding
D)
None of the above

Correct Answer :   method overloading

144 .
What is the process of defining a method in terms of itself, that is a method that calls itself?
A)
Polymorphism
B)
Abstraction
C)
Encapsulation
D)
Recursion

Correct Answer :   Recursion

145 .
What will be the output of the following Java code?
 
    class test 
    {
        int a;
        int b;
        void meth(int i , int j) 
        {
            i *= 2;
            j /= 2;
        }          
    }    
    class Output 
    {
        public static void main(String args[])
        {
            test obj = new test();
	    int a = 10;
            int b = 20;             
            obj.meth(a , b);
            System.out.println(a + " " + b);        
        } 
    }
A)
10 20
B)
20 10
C)
20 40
D)
40 20

Correct Answer :   10 20

146 .
Which of these is used to access a member of class before object of that class is created?
A)
public
B)
private
C)
static
D)
protected

Correct Answer :   static

147 .
What is the process by which we can control what parts of a program can access the members of a class?
A)
Polymorphism
B)
Abstraction
C)
Recursion
D)
Encapsulation

Correct Answer :   Encapsulation

148 .
What will be the output of the following Java code?
 
    class static_out 
    {
        static int x;
 	static int y;
        void add(int a, int b)
        {
            x = a + b;
            y = x + b;
        }
    }    
    public class static_use 
    {
        public static void main(String args[])
        {
            static_out obj1 = new static_out();
            static_out obj2 = new static_out();   
            int a = 2;
            obj1.add(a, a + 1);
            obj2.add(5, a);
            System.out.println(obj1.x + " " + obj2.y);     
        }
   }
A)
7 9
B)
9 7
C)
6 6.4
D)
7 7.4

Correct Answer :   7 9

149 .
Which of these method of String class can be used to test to strings for equality?
A)
isequal()
B)
sequals()
C)
equal()
D)
equals()

Correct Answer :   equals()

150 .
What will be the output of the following Java program?
 
    class string_class 
    {
        public static void main(String args[])
        {
            String obj = "I LIKE JAVA";   
            System.out.println(obj.charAt(3));
        } 
    }
A)
I
B)
L
C)
K
D)
E

Correct Answer :   I

151 .
What will be the output of the following Java program?
 
    class string_class 
    {
        public static void main(String args[])
        {
            String obj = "I LIKE JAVA";   
            System.out.println(obj.length());
        }
    }
A)
9
B)
10
C)
11
D)
12

Correct Answer :   11

152 .
Which of this method is given parameter via command line arguments?
A)
main()
B)
recursive() method
C)
System defined methods
D)
Any method

Correct Answer :   main()

153 .
Which of these is a correct statement about args in the following line of code?
 
public static void main(String args[])
 
A)
args is a String
B)
args is a Character
C)
args is an array of String
D)
args in an array of Character

Correct Answer :   args is an array of String

154 .
What will be the output of the following Java program, Command line execution is done as – “java Output This is a command Line”?
 
    class Output 
    {
        public static void main(String args[]) 
        {
            System.out.print("args[0]");
        }
    }
A)
java
B)
This
C)
Output
D)
is

Correct Answer :   This

155 .
What will be the output of the following Java program, Command line exceution is done as – “java Output This is a command Line”?
 
    class Output 
    {
        public static void main(String args[]) 
        {
            System.out.print("args[3]");
        }
    }
A)
is
B)
This
C)
java
D)
command

Correct Answer :   command

156 .
What will be the output of the following Java program, Command line execution is done as – “java Output This is a command Line”?
 
    class Output 
    {
        public static void main(String args[]) 
        {
            System.out.print("args");
        }
    }
A)
This
B)
Compilation Error
C)
This is a command Line
D)
java Output This is a command Line

Correct Answer :   This is a command Line

157 .
What will be the output of the following Java program, Command line execution is done as – “java Output command Line 10 A b 4 N”?
 
    class Output 
    {
        public static void main(String args[]) 
        {
            System.out.print("(int)args[2] * 2");
        }
    }
A)
10
B)
20
C)
java
D)
None of the above

Correct Answer :   20

158 .
What will be the output of the following Java program, Command line execution is done as – “java Output command Line 10 A b 4 N”?

    class Output 
    {
        public static void main(String args[]) 
        {
            System.out.print("args[6]");
        }
    }​
A)
N
B)
java
C)
10 
D)
None of the above

Correct Answer :   N

159 .
What is Recursion in Java?
A)
Recursion is a class
B)
Recursion is a process of defining a method that calls other methods repeatedly
C)
Recursion is a process of defining a method that calls itself repeatedly
D)
Recursion is a process of defining a method that calls other methods which in turn call again this method

Correct Answer :   Recursion is a process of defining a method that calls other methods repeatedly

160 .
Which of these will happen if recursive method does not have a base case?
A)
An infinite loop occurs
B)
System stops the program after some time
C)
After 1000000 calls it will be automatically stopped
D)
None of the above

Correct Answer :   An infinite loop occurs

161 .
Which of these packages contains the exception Stack Overflow in Java?
A)
java.lang
B)
java.util
C)
java.io
D)
java.system

Correct Answer :   java.lang

162 .
What will be the output of the following Java program?
 
    class recursion 
    {
        int func (int n) 
        {
            int result;
            if (n == 1)
                return 1;
            result = func (n - 1);
            return result;
        }
    } 
    class Output 
    {
        public static void main(String args[]) 
        {
            recursion obj = new recursion() ;
            System.out.print(obj.func(5));
        }
    }
A)
0
B)
1
C)
12
D)
None of the above

Correct Answer :   1

163 .
What is the process of defining a method in a subclass having same name & type signature as a method in its superclass?
A)
Method hiding
B)
Method overloading
C)
Method overriding
D)
None of the above

Correct Answer :   Method overriding

164 .
At line number 2 in the following code, choose 3 valid data-type attributes/qualifiers among “final, static, native, public, private, abstract, protected”
 
public interface Status
   {
        /* insert qualifier here */ int MY_VALUE = 10;
   }
A)
final, native, private
B)
final, static, protected
C)
final, private, abstract
D)
final, static, public

Correct Answer :   final, static, public

165 .
What will be the output of the following Java program?
 
  class Abc
  {
      public static void main(String[]args)
      {
          String[] elements = { "for", "tea", "too" };
          String first = (elements.length > 0) ? elements[0]: null;
      }
  }
A)
Compilation error
B)
The variable first is set to null
C)
An exception is thrown at run time
D)
The variable first is set to elements[0]

Correct Answer :   The variable first is set to elements[0]

166 .
Which of these keywords are used to define an abstract class?
A)
abst
B)
abstract
C)
Abstract
D)
abstract class

Correct Answer :   abstract

167 .
What will be the output of the following Java code?
 
    class A 
    {
        public int i;
        protected int j;
    }    
    class B extends A 
    {
        int j;
        void display() 
        {
            super.j = 3;
            System.out.println(i + " " + j);
        }
    }    
    class Output 
    {
        public static void main(String args[])
        {
            B obj = new B();
            obj.i=1;
            obj.j=2;   
            obj.display();     
        }
   }
A)
1 2
B)
1 3
C)
2 1
D)
3 1

Correct Answer :   1 2

168 .
A class member declared protected becomes a member of subclass of which type?
A)
public member
B)
private member
C)
static member
D)
protected member

Correct Answer :   private member

169 .
Which of these is correct way of inheriting class A by class B?
A)
class B + class A {}
B)
class B extends A {}
C)
class B inherits class A {}
D)
class B extends class A {}

Correct Answer :   class B extends A {}

170 .
What will be the output of the following Java 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();     
        }
   }
A)
0
B)
1
C)
2
D)
Compilation Error

Correct Answer :   2

171 .
Which of the following methods is a method of wrapper Integer for obtaining hash code for the invoking object?
A)
int hash()
B)
int hashcode()
C)
int hashCode()
D)
Integer hashcode()

Correct Answer :   int hashCode()

172 .
Which of these methods is used to obtain value of invoking object as a long?
A)
long value()
B)
long longValue()
C)
Long longvalue()
D)
Long Longvalue()

Correct Answer :   long longValue()

173 .
What will be the output of the following Java program?
 
    class Output 
    {
        public static void main(String args[]) 
        {
            char a[] = {'a', '5', 'A', ' '};   
            System.out.print(Character.isDigit(a[0]) + " ");
            System.out.print(Character.isWhitespace(a[3]) + " ");
            System.out.print(Character.isUpperCase(a[2]));
        }
    }
A)
true false true
B)
false true true
C)
true true false
D)
false false false

Correct Answer :   false true true

174 .
What will be the output of the following Java program?
 
    class Output 
    {
        public static void main(String args[]) 
        {
            Integer i = new Integer(257);  
            byte x = i.byteValue();
            System.out.print(x);
        }
    }
A)
257
B)
256
C)
1
D)
0

Correct Answer :   1

175 .
What will be the output of the following Java program?
 
    class Output 
    {
        public static void main(String args[]) 
        {
            Long i = new Long(256);  
            System.out.print(i.hashCode());
        }
    }
A)
256
B)
256.0
C)
256.00
D)
257.00

Correct Answer :   257

176 .
Which of the following method of Process class can terminate a process?
A)
void kill()
B)
void destroy()
C)
void exit()
D)
void terminate()

Correct Answer :   void destroy()

177 .
Which of the following is method of System class is used to find how long a program takes to execute?
A)
currenttime()
B)
currentTime()
C)
currentTimeMillis()
D)
currenttimeMillis()

Correct Answer :   currentTimeMillis()

178 .
What will be the output of the following Java code?
 
    class Output 
    {
        public static void main(String args[]) 
        {
            long start, end;   
            start = System.currentTimeMillis();
            for (int i = 0; i < 10000000; i++);
            end = System.currentTimeMillis();
            System.out.print(end - start);
        }
    }
A)
0
B)
1
C)
1000
D)
System Dependent

Correct Answer :   System Dependent

179 .
What will be the output of the following Java code?
 
    class Output 
    {
        public static void main(String args[]) 
        {
            byte a[] = { 65, 66, 67, 68, 69, 70 };
            byte b[] = { 71, 72, 73, 74, 75, 76 };  
            System.arraycopy(a , 0, b, 0, a.length);
            System.out.print(new String(a) + " " + new String(b));
        }
    }
A)
ABCDEF ABCDEF
B)
ABCDEF GHIJKL
C)
GHIJKL ABCDEF
D)
GHIJKL GHIJKL

Correct Answer :   ABCDEF ABCDEF

180 .
What will be the output of the following Java code?
 
    class Output 
    {
        public static void main(String args[]) 
        {
            byte a[] = { 65, 66, 67, 68, 69, 70 };
            byte b[] = { 71, 72, 73, 74, 75, 76 };  
            System.arraycopy(a, 1, b, 3, 0);
            System.out.print(new String(a) + " " + new String(b));
        }
    }
A)
ABCDEF GHIJKL
B)
ABCDEF GCDEFL
C)
GHIJKL ABCDEF
D)
GCDEFL GHIJKL

Correct Answer :   ABCDEF GHIJKL

181 .
Which of these class is a superclass of all other classes?
A)
Math
B)
Process
C)
System
D)
Object

Correct Answer :   Object

182 .
What is the value of double consonant ‘E’ defined in Math class?
A)
approximately 0
B)
approximately 2.72
C)
approximately 3
D)
approximately 3.14

Correct Answer :   approximately 2.72

183 .
What is the value of “d” in the following Java code snippet?
 
  double d = Math.round ( 2.5 + Math.random() );
A)
2
B)
2.5
C)
3
D)
4

Correct Answer :   3

184 .
What will be the output of the following Java program?
 
    class Output 
    {
         public static void main(String args[]) 
         {
             int x = 3.14;  
             int y = (int) Math.abs(x);
             System.out.print(y);
         }
    }
A)
0
B)
3
C)
3.0
D)
3.1

Correct Answer :   3

185 .
What will be the output of the following Java program?
 
    class Output 
    {
         public static void main(String args[]) 
        {
            double x = 3.1;  
            double y = 4.5;
            double z = Math.max( x, y );
            System.out.print(z);
        }
    }
A)
True
B)
False
C)
3.1
D)
4.5

Correct Answer :   4.5

186 .
What will be the output of the following Java program?
 
    class Output 
    {
         public static void main(String args[]) 
        {
            double x = 2.0;  
            double y = 3.0;
            double z = Math.pow( x, y );
            System.out.print(z);
        }
    }
A)
2.0
B)
4.0
C)
8.0
D)
9.0

Correct Answer :   8.0

187 .
Which of these methods initiates garbage collection?
A)
gc()
B)
garbage()
C)
garbagecollection()
D)
Systemgarbagecollection()

Correct Answer :   gc()

188 .
Which of these methods loads the specified dynamic library?
A)
load()
B)
loadlib()
C)
library()
D)
loadlibrary()

Correct Answer :   load()

189 .
What will be the output of the following Java program?
 
    import java.lang.System;
    class Output 
    {
        public static void main(String args[])
        {
            System.exit(5);
        }
    }
A)
0
B)
1
C)
4
D)
5

Correct Answer :   5

190 .
Which of the following methods return the value as a double?
A)
getDouble()
B)
doubleValue()
C)
converDouble()
D)
getDoubleValue()

Correct Answer :   doubleValue()

191 .
What will be the output of the following Java code?
 
    class Output 
    {
        public static void main(String args[])
        {
            Double i = new Double(257.5);  
            boolean x = i.isNaN();
            System.out.print(x);
        }
    }
A)
True
B)
False
C)
0
D)
1

Correct Answer :   False

192 .
What will be the output of the following Java code?
 
    class Output
    {
        public static void main(String args[])
        {
	    Double i = new Double(257.578123456789);  
            float x = i.floatValue();
            System.out.print(x);
        }
    }
A)
0
B)
257.0
C)
257.57812
D)
257.578123456789

Correct Answer :   257.57812

193 .
What will be the output of the following Java code?
 
    import java.io.*;
    class files 
    {
        public static void main(String args[]) 
        {
            File obj = new File("/java/system");
            System.out.print(obj.getName());
        }
    }
A)
java
B)
system
C)
java/system
D)
/java/system

Correct Answer :   system

194 .
Which of these method(s) is/are used for writing bytes to an outputstream?
A)
put()
B)
printf()
C)
print() and write()
D)
write() and read()

Correct Answer :   print() and write()

195 .
What will be the output of the following Java program? (Note: inputoutput.java is stored in the disk.)
 
    import java.io.*;
    class filesinputoutput 
    {
        public static void main(String args[]) 
        {
            InputStream obj = new FileInputStream("inputoutput.java");
            System.out.print(obj.available());
        }
    }
A)
true
B)
false
C)
prints number of bytes in file
D)
prints number of characters in the file

Correct Answer :   prints number of bytes in file

196 .
Which of these stream contains the classes which can work on character stream?
A)
Character Stream
B)
InputStream
C)
OutputStream
D)
All of the above

Correct Answer :   Character Stream

197 .
Which of these class can be used to implement the input stream that uses a character array as the source?
A)
BufferedReader
B)
FileReader
C)
FileArrayReader
D)
CharArrayReader

Correct Answer :   CharArrayReader

198 .
What is the Java 8 update of PermGen?
A)
Code Cache
B)
Metaspace
C)
Tenured Space
D)
Eden space

Correct Answer :   Metaspace

199 .
Where is String Pool stored?
A)
Java Stack
B)
Metaspace
C)
Permanent Generation
D)
Java Heap

Correct Answer :   Java Heap

200 .
Which of these exceptions handles the situations when an illegal argument is used to invoke a method?
A)
IllegalException
B)
Argument Exception
C)
IllegalArgumentException
D)
IllegalMethodArgumentExcepetion

Correct Answer :   IllegalArgumentException

201 .
What will be the output of the following Java program?
 
    class exception_handling 
    {
        public static void main(String args[]) 
        {
            try 
            {
                int a[] = {1, 2,3 , 4, 5};
                for (int i = 0; i < 7; ++i) 
                    System.out.print(a[i]);
            }
            catch(ArrayIndexOutOfBoundsException e) 
            {
        	System.out.print("0");        	
            }
        }
    }
A)
12345
B)
123450
C)
1234500
D)
Compilation Error

Correct Answer :   123450

202 .
Which of these methods return a smallest whole number greater than or equal to variable X?
A)
double ceil(double X)
B)
double floor(double X)
C)
double max(double X)
D)
double min(double X)

Correct Answer :   double ceil(double X)

203 .
What will be the output of the following Java code?
 
    class Output 
    {
         public static void main(String args[]) 
         {
             double x = 3.14;  
             int y = (int) Math.abs(x);
             System.out.print(y);
         }
    }
A)
0
B)
3
C)
3.0
D)
3.1

Correct Answer :   3

204 .
What will be the output of the following Java code?
 
    class Output 
    {
         public static void main(String args[]) 
         {
             double x = 3.14;  
             int y = (int) Math.ceil(x);
             System.out.print(y);
         }
    }
A)
0
B)
3
C)
3.0
D)
4

Correct Answer :   4

205 .
Which of the following methods Byte wrapper return the value as a double?
A)
doubleValue()
B)
getDouble()
C)
getDoubleValue()
D)
converDouble()

Correct Answer :   doubleValue()

206 .
What will be the output of the following Java code?
 
    class Output 
    {
        public static void main(String args[])
        {
            Double i = new Double(257.5);  
            Double x = i.MAX_VALUE;
            System.out.print(x);
        }
    }
A)
0
B)
1.7976931348623157E308
C)
1.7976931348623157E30
D)
None of the above

Correct Answer :   1.7976931348623157E308

207 .
What will be the output of the following Java program?
 
    class Output
    {
        public static void main(String args[])
        {
            Double i = new Double(257.5);  
            Double x = i.MIN_VALUE;
            System.out.print(x);
        }
    }
A)
4.9E-324
B)
1.7976931348623157E308
C)
0
D)
None of the above

Correct Answer :   4.9E-324

208 .
Which of these methods of Character wrapper can be used to obtain the char value contained in Character object.
A)
get()
B)
getVhar()
C)
charValue()
D)
getCharacter()

Correct Answer :   charValue()

209 .
Which of the following constant are defined in Character wrapper?
A)
TYPE
B)
MAX_RADIX
C)
MAX_VALUE
D)
All of the above

Correct Answer :   All of the above

210 .
What will be the output of the following Java program?
 
    class Output 
    {
        public static void main(String args[]) 
        {
            int a = Character.MAX_VALUE;
            System.out.print((char)a);
        }
    }
A)
?
B)
$
C)
<
D)
>

Correct Answer :   ?

211 .
What will be the output of the following Java program?
 
    class Output
    {
        public static void main(String args[])
        {
            int a = Character.MIN_VALUE;
            System.out.print((char)a);
        }
    }
A)
<
B)
@
C)
!
D)
Space

Correct Answer :   Space

212 .
What will be the output of the following Java program?
 
    class Output
    {
        public static void main(String args[])
        {
	    char a = (char) 98;
            a = Character.toUpperCase(a);
            System.out.print(a);
        }
    }
A)
b
B)
B
C)
c
D)
C

Correct Answer :   B

213 .
Which of these methods of Boolean wrapper returns boolean equivalent of an object.
A)
getBool()
B)
booleanValue()
C)
getboolValue()
D)
getbooleanValue()

Correct Answer :   booleanValue()

214 .
Which of these methods return string equivalent of Boolean object?
A)
toString()
B)
getString()
C)
converString()
D)
getStringObject()

Correct Answer :   toString()

215 .
What will be the output of the following Java program?
 
    class Output
    {
        public static void main(String args[])
        {
            String str = "true false true";
            boolean x = Boolean.valueOf(str);
            System.out.print(x);
        }
    }
A)
True
B)
False
C)
Runtime Error
D)
Compilation Error

Correct Answer :   False

216 .
Which of these method returns the remainder of dividend / divisor?
A)
remainder()
B)
getRemainder()
C)
CSIremainder()
D)
IEEEremainder()

Correct Answer :   IEEEremainder()

217 .
Which of these method returns a smallest whole number greater than or equal to variable X?
A)
double ciel(double X)
B)
double floor(double X)
C)
double max(double X)
D)
double min(double X)

Correct Answer :   double ciel(double X)

218 .
What will be the output of the following Java program?
 
    class Output 
    {
        public static void main(String args[]) 
        {
            double x = 3.14;  
            int y = (int) Math.toDegrees(x);
            System.out.print(y);
        }
    }
A)
0
B)
179
C)
180
D)
360

Correct Answer :   179

219 .
What will be the output of the following Java program?
 
    class Output 
    {
        public static void main(String args[]) 
        {
            double x = 102;
            double y = 5;
            double z = Math.IEEEremainder(x, y);
            System.out.print(z);}
         }
    }
A)
0
B)
1
C)
2
D)
3

Correct Answer :   2

220 .
Which of the following exceptions is thrown by every method of Runtime class?
A)
IOException
B)
RuntimeException
C)
SystemException
D)
SecurityException

Correct Answer :   SecurityException

221 .
Which of these methods returns the total number of bytes of memory available to the program?
A)
getMemory()
B)
TotalMemory()
C)
SystemMemory()
D)
getProcessMemory()

Correct Answer :   TotalMemory()

222 .
Which of these methods return a class object given its name?
A)
getClass()
B)
findClass()
C)
getSystemClass()
D)
findSystemClass()

Correct Answer :   findSystemClass()

223 .
What will be the output of the following Java program?
 
    class X
    {
        int a;
        double b;
    }
    class Y extends X 
    {
	int c;
    }
    class Output 
    {
        public static void main(String args[]) 
        {
            X a = new X();
            Y b = new Y();
            Class obj;
            obj = b.getClass();
            System.out.print(obj.getSuperclass());
        }
    }
A)
X
B)
Y
C)
class X
D)
class Y

Correct Answer :   class X

224 .
Which of the interface contains all the methods used for handling thread related operations in Java?
A)
Runnable interface
B)
System interface
C)
Math interface
D)
ThreadHandling interface

Correct Answer :   Runnable interface

225 .
Which of these methods of a Thread class is used to suspend a thread for a period of time?
A)
sleep()
B)
stop()
C)
terminate()
D)
suspend()

Correct Answer :   sleep()

226 .
What will be the output of the following Java program?
 
    class newthread implements Runnable 
    {
	Thread t;
        newthread() 
        {
            t = new Thread(this,"My Thread");
            t.start();
	}
	public void run() 
        {
	    System.out.println(t);
	}
    }
    class multithreaded_programing 
    {
        public static void main(String args[]) 
        {
            new newthread();        
        }
    }
A)
My Thread
B)
Thread[My Thread,5,main]
C)
Runtime Error
D)
Compilation Error

Correct Answer :   Thread[My Thread,5,main]

227 .
Which of these process occur automatically by the java runtime system?
A)
Serialization
B)
Garbage collection
C)
File Filtering
D)
All of the above

Correct Answer :   Serialization

228 .
Which of these is method of ObjectOutput interface used to write the object to input or output stream as required?
A)
write()
B)
Write()
C)
StreamWrite()
D)
writeObject()

Correct Answer :   writeObject()

229 .
Which of these is a method of ObjectInput interface used to deserialize an object from a stream?
A)
int read()
B)
void close()
C)
Object readObject()
D)
Object WriteObject()

Correct Answer :   void close()

230 .
Which of these is a protocol for breaking and sending packets to an address across a network?
A)
DNS
B)
TCP/IP
C)
Socket
D)
Proxy Server

Correct Answer :   TCP/IP

231 .
How many ports of TCP/IP are reserved for specific protocols?
A)
10
B)
512
C)
1024
D)
2048

Correct Answer :   1024

232 .
Which of these class is used to encapsulate IP address and DNS?
A)
URL
B)
InetAddress
C)
DatagramPacket
D)
ContentHandler

Correct Answer :   InetAddress

233 .
Which of these interface abstractes the output of messages from httpd?
A)
LogMessage
B)
LogResponse
C)
Httpdserver
D)
httpdResponse

Correct Answer :   LogMessage

234 .
Which of these methods is used to make raw MIME formatted string?
A)
parseString()
B)
getString()
C)
toString()
D)
parse()

Correct Answer :   parse()

235 .
What will be the output of the following Java program?
 
    import java.net.*;
    class networking 
    {
        public static void main(String[] args) throws MalformedURLException 
        {
            URL obj = new URL("https://www.freetimelearning.com/java");
            System.out.print(obj.toExternalForm());
        }
    }
A)
freetimelearning
B)
freetimelearning.com
C)
www.freetimelearning.com
D)
https://www.freetimelearning.com/java

Correct Answer :   https://www.freetimelearning.com/java

236 .
Which of these methods is used to know the full URL of an URL object?
A)
ExternalForm()
B)
toExternalForm()
C)
getHost()
D)
fullHost()

Correct Answer :   toExternalForm()

237 .
What will be the output of the following Java code?
 
    import java.net.*;
    class networking 
    {
        public static void main(String[] args) throws MalformedURLException 
        {
            URL obj = new URL("https://www.freetimelearning.com/java");
            System.out.print(obj.getProtocol());
        }
    }
A)
http
B)
https
C)
www
D)
com

Correct Answer :   http

238 .
Which of these methods is used to know when was the URL last modified?
A)
LastModified()
B)
getLastModified()
C)
GetLastModified()
D)
getlastModified()()

Correct Answer :   getLastModified()

239 .
Which of these class is necessary to implement datagrams?
A)
DatagramPacket
B)
DatagramSocket
C)
All of the above
D)
None of the above

Correct Answer :   All of the above

240 .
Which API gets the SocketAddress (usually IP address + port number) of the remote host that this packet is being sent to or is coming from.
A)
getSocketAddress()
B)
getAddress()
C)
address()
D)
None of the above

Correct Answer :   getSocketAddress()

241 .
Which of these keywords is used to manually throw an exception?
A)
try
B)
catch
C)
throw
D)
finally

Correct Answer :   throw

242 .
What will be the output of the following Java program?
 
    class exception_handling 
    {
        public static void main(String args[]) 
        {
            try 
            {
                System.out.print("Hello" + " " + 1 / 0);
            }
            catch(ArithmeticException e) 
            {
        	System.out.print("World");        	
            }
        }
    }
A)
Hello
B)
World
C)
HelloWorld
D)
None of the above

Correct Answer :   World

243 .
What will be the output of the following Java program?
 
    class exception_handling 
    {
        public static void main(String args[]) 
        {
            try 
            {
                int i, sum;
                sum = 10;
                for (i = -1; i < 3 ;++i)
                    sum = (sum / i);
            }
            catch(ArithmeticException e) 
            {
        	System.out.print("0");        	
            } 
            System.out.print(sum);
        }
    }
A)
0
B)
05
C)
Runtime Error
D)
Compilation Error

Correct Answer :   Compilation Error

244 .
A single try block must be followed by which of these?
A)
finally
B)
catch
C)
finally & catch
D)
None of the above

Correct Answer :   finally & catch

245 .
Which of these exceptions handles the divide by zero error?
A)
ArithmeticException
B)
MathException
C)
IllegarException
D)
IllegalAccessException

Correct Answer :   ArithmeticException

246 .
What will be the output of the following Java code?
 
    class exception_handling 
    {
        public static void main(String args[]) 
        {
            try 
            {
                throw new NullPointerException ("Hello");
            }
            catch(ArithmeticException e)
            {
        	System.out.print("B");        	
            }
        }
    }
A)
A
B)
B
C)
Compilation Error
D)
Runtime Error

Correct Answer :   Runtime Error

247 .
Which of these classes is used to define exceptions?
A)
Exception
B)
Throwable
C)
Abstract
D)
System

Correct Answer :   Exception

248 .
Which of these methods return description of an exception?
A)
getException()
B)
getMessage()
C)
obtainDescription()
D)
obtainException()

Correct Answer :   getMessage()

249 .
Which of this method is used to find out that a thread is still running or not?
A)
run()
B)
Alive()
C)
isAlive()
D)
checkRun()

Correct Answer :   isAlive()

250 .
What is synchronization in reference to a thread?
A)
It’s a process of handling situations when two or more threads need access to a shared resource
B)
It’s a process by which many thread are able to access same shared resource simultaneously
C)
It’s a process by which a method is able to access many different threads simultaneously
D)
It’s a method that allow too many threads to access any information require

Correct Answer :   It’s a process of handling situations when two or more threads need access to a shared resource

251 .
What will be the output of the following Java code?
 
    class newthread extends Thread
    {
	Thread t1,t2;
	newthread()
        {
	    t1 = new Thread(this,"Thread_1");
	    t2 = new Thread(this,"Thread_2");
	    t1.start();
	    t2.start();
	}
	public void run()
        {
	    t2.setPriority(Thread.MAX_PRIORITY);	
	    System.out.print(t1.equals(t2));
        }    
    }
    class multithreaded_programing
    {
        public static void main(String args[])
        {
            new newthread();        
        }
    }
A)
true
B)
false
C)
truetrue
D)
falsefalse

Correct Answer :   falsefalse

252 .
Which of these method is used to implement Runnable interface?
A)
stop()
B)
run()
C)
runThread()
D)
stopThread()

Correct Answer :   run()

253 .
Which of these statement is incorrect?
A)
A thread can be formed by implementing Runnable interface only
B)
A thread can be formed by a class that extends Thread class
C)
start() method is used to begin execution of the thread
D)
run() method is used to begin execution of a thread before start() method in special cases

Correct Answer :   run() method is used to begin execution of a thread before start() method in special cases

254 .
What will be the output of the following Java code?
 
    class newthread implements Runnable
    {
	Thread t;
	newthread()
        {
	    t = new Thread(this,"My Thread");
	    t.start();
	}
	public void run()
        {
	    System.out.println(t);
	}
    }
    class multithreaded_programing
    {
        public static void main(String args[])
        {
            new newthread();        
        }
    }
A)
My Thread
B)
Thread[My Thread,5,main]
C)
Runtime Error
D)
Compilation Error

Correct Answer :   Thread[My Thread,5,main]

255 .
What will be the output of the following Java code?
 
    class newthread implements Runnable
    {
	Thread t;
	newthread()
        {
	    t = new Thread(this,"New Thread");
	    t.start();
	}
	public void run()
        {
	    t.setPriority(Thread.MAX_PRIORITY);	
            System.out.println(t);
	}
    }
    class multithreaded_programing
    {
        public static void main(String args[])
        {
            new newthread();        
        }
    }
A)
Thread[New Thread,0,main]
B)
Thread[New Thread,1,main]
C)
Thread[New Thread,5,main]
D)
Thread[New Thread,10,main]

Correct Answer :   Thread[New Thread,10,main]

256 .
Which of these method of Thread class is used to find out the priority given to a thread?
A)
get()
B)
ThreadPriority()
C)
getPriority()
D)
getThreadPriority()

Correct Answer :   getPriority()

257 .
Which function of pre defined class Thread is used to check weather current thread being checked is still running?
A)
isAlive()
B)
Alive()
C)
Join()
D)
isRunning()

Correct Answer :   isAlive()

258 .
What will be the output of the following Java code?
 
    class multithreaded_programing
    {
        public static void main(String args[])
        {
            Thread t = Thread.currentThread();
            t.setName("New Thread");
            System.out.println(t);        
        }
    }
A)
Thread[5,main]
B)
Thread[New Thread,5]
C)
Thread[main,5,main]
D)
Thread[New Thread,5,main]

Correct Answer :   Thread[New Thread,5,main]

259 .
What is multithreaded programming?
A)
It’s a process in which two different processes run simultaneously
B)
It’s a process in which two or more parts of same process run simultaneously
C)
It’s a process in which many different process are able to access same information
D)
It’s a process in which a single process can access information from many sources

Correct Answer :   It’s a process in which two or more parts of same process run simultaneously

260 .
What will be the output of the following Java code?
 
    class multithreaded_programing
    {
        public static void main(String args[])
        {
            Thread t = Thread.currentThread();
            System.out.println(t);        
        }
    }
A)
Thread[5,main]
B)
Thread[main,0]
C)
Thread[main,5]
D)
Thread[main,5,main]

Correct Answer :   Thread[main,5,main]

261 .
Which of these method is used to tell the calling thread to give up a monitor and go to sleep until some other thread enters the same monitor?
A)
wait()
B)
notify()
C)
sleep()
D)
notifyAll()

Correct Answer :   wait()

262 .
Which of these method wakes up all the threads?
A)
start()
B)
notify()
C)
notifyAll()
D)
wakeAll()

Correct Answer :   notifyAll()

263 .
What does AWT stands for?
A)
All Window Tools
B)
All Writing Tools
C)
Abstract Window Toolkit
D)
Abstract Writing Toolkit

Correct Answer :   Abstract Window Toolkit

264 .
Which of these classes are used by Byte streams for input and output operation?
A)
Reader
B)
InputStream
C)
InputOutputStream
D)
All of the above

Correct Answer :   InputStream

265 .
Which of these class is used to read from byte array?
A)
InputStream
B)
BufferedInputStream
C)
ArrayInputStream
D)
ByteArrayInputStream

Correct Answer :   ByteArrayInputStream

266 .
What will be the output of the following Java program if input given is “abc’def/’egh”?
 
    class Input_Output
    {
        public static void main(String args[]) throws IOException
        {	 
            char c;
            BufferedReader obj = new BufferedReader(new InputStreamReader(System.in));
            do 
            {
                c = (char) obj.read();
	        System.out.print(c);
            } while(c!='\'');
        }
    }
A)
abc’
B)
abcdef/’
C)
abc’def/’egh
D)
abcqfghq

Correct Answer :   abc’

267 .
What will be the output of the following Java program?
 
    class output
    {
        public static void main(String args[])
        { 
             StringBuffer c = new StringBuffer("Hello");
             System.out.println(c.length());
        }
    }
A)
4
B)
5
C)
6
D)
7

Correct Answer :   5

268 .
Which of these methods can be used to output a string in an applet?
A)
print()
B)
display()
C)
drawString()
D)
transient()

Correct Answer :   drawString()

269 .
What is the Message is displayed in the applet made by the following Java program?
 
    import java.awt.*;
    import java.applet.*;
    public class myapplet extends Applet
    {
        public void paint(Graphics g)
        {
            g.drawString("A Simple Applet", 20, 20);    
        }
    }
A)
A Simple Applet
B)
A Simple Applet 20 20
C)
Runtime Error
D)
Compilation Error

Correct Answer :   A Simple Applet

270 .
What is the length of the application box made by the following Java program?
 
    import java.awt.*;
    import java.applet.*;
    public class myapplet extends Applet
    {
        public void paint(Graphics g)
        {
            g.drawString("A Simple Applet", 20, 20);    
        }
    }
A)
20
B)
50
C)
100
D)
System dependent

Correct Answer :   20

271 .
Which of the following is not a class of java.util.regex?
A)
Pattern class
B)
matcher class
C)
Regex class
D)
PatternSyntaxException

Correct Answer :   Regex class

272 .
Which capturing group can represent the entire expression?
A)
group *
B)
group 0
C)
group * or group 0
D)
None of the above

Correct Answer :   group 0

273 .
What does public int start() return?
A)
returns start index of the input string
B)
returns start index of the current match
C)
returns start index of the previous match
D)
None of the above

Correct Answer :   returns start index of the previous match

274 .
Which of these packages contains all the classes and methods required for even handling in Java?
A)
java.applet
B)
java.event
C)
java.awt
D)
java.awt.event

Correct Answer :   java.awt.event

275 .
Which of these methods are used to register a keyboard event listener?
A)
KeyListener()
B)
addKistener()
C)
addKeyListener()
D)
eventKeyboardListener()

Correct Answer :   addKeyListener()

276 .
Which of these methods can be used to determine the type of event?
A)
getID()
B)
getEvent()
C)
getSource()
D)
getEventObject()

Correct Answer :   getID()

277 .
Which of these events will be generated if we close an applet’s window?
A)
ActionEvent
B)
WindowEvent
C)
ComponentEvent
D)
AdjustmentEvent

Correct Answer :   WindowEvent

278 .
Which of these methods can be used to obtain the coordinates of a mouse?
A)
getPoint()
B)
getCoordinates()
C)
getMouseXY()
D)
getMouseCordinates()

Correct Answer :   getPoint()

279 .
Which of these are integer constants of TextEvent class?
A)
TEXT_CHANGED
B)
TEXT_FORMAT_CHANGED
C)
TEXT_VALUE_CHANGED
D)
TEXT_SIZE_CHANGED

Correct Answer :   TEXT_VALUE_CHANGED

280 .
Which of these methods is used to get x coordinate of the mouse?
A)
getX()
B)
getXCoordinate()
C)
getCoordinateX()
D)
getPointX()

Correct Answer :   getX()

281 .
Which class is used to generate random number?
A)
java.lang.Object
B)
java.util.Random
C)
java.util.Object
D)
java.util.randomNumber

Correct Answer :   java.util.Random

282 .
Which method is used to generate boolean random values in java?
A)
nextBoolean()
B)
randomBoolean()
C)
previousBoolean()
D)
generateBoolean()

Correct Answer :   nextBoolean()

283 .
What will be the output of the following Java code snippet?
 
int a = random.nextInt(15) + 1;
A)
Random number between 1 to 15, excluding 1
B)
Random number between 1 to 15, excluding 15
C)
Random number between 1 to 15, excluding 1 and 15
D)
Random number between 1 to 15, including 1 and 15

Correct Answer :   Random number between 1 to 15, including 1 and 15

284 .
What is the signature of Math.random() method?
A)
public void int random()
B)
 public static int random()
C)
public static double random()
D)
public void double random()

Correct Answer :   public static double random()

285 .
Which of these class produce objects with respect to geographical locations?
A)
Date
B)
Locale
C)
TimeZone
D)
SimpleTimeZone

Correct Answer :   Locale

286 .
Which of these method of Locale class can be used to obtain country of operation?
A)
getCountry()
B)
whichCountry()
C)
DisplayCountry()
D)
getDisplayCountry()

Correct Answer :   getDisplayCountry()

287 .
What will be the output of the following Java program?
 
    import java.util.*;
    class LOCALE_CLASS
    {
        public static void main(String args[])
        {
            Locale obj = new Locale("HINDI", "INDIA") ;
            System.out.print(obj.getCountry());
        }
    }
A)
India
B)
INDIA
C)
Compilation Error
D)
Nothing is displayed

Correct Answer :   INDIA

288 .
What will be the output of the following Java program?
 
    import java.util.*;
    class LOCALE_CLASS
    {
        public static void main(String args[])
        {
            Locale obj = new Locale("HINDI") ;
            System.out.print(obj.getDisplayLanguage());
        }
    }
A)
India
B)
INDIA
C)
HINDI
D)
Nothing is displayed

Correct Answer :   HINDI

289 .
Which of these is a mechanism for naming and visibility control of a class and its content?
A)
Object
B)
Packages
C)
Interfaces
D)
None of the above

Correct Answer :   Packages

290 .
Which of the following is the correct way of importing an entire package ‘pkg’?
A)
import pkg.
B)
Import pkg.
C)
import pkg.*
D)
Import pkg.*

Correct Answer :   import pkg.*

291 .
What will be the output of the following Java program?
 
    package pkg;
    class output 
    {
        public static void main(String args[])
        { 
            StringBuffer s1 = new StringBuffer("Hello");
            s1.setCharAt(1, x);
            System.out.println(s1);
        }
    }
A)
Hxllo
B)
Hexlo
C)
xxxxx
D)
xello

Correct Answer :   Hxllo

292 .
What will be the output of the following Java program?
 
    package pkg;
    class output 
    {
        public static void main(String args[])
        {
            StringBuffer s1 = new StringBuffer("Hello World");
            s1.insert(6 , "Good ");
            System.out.println(s1);
        }
   }

Note : Output.class file is not in directory pkg.

A)
HelloGoodWorld
B)
HellGoodoWorld
C)
Compilation error
D)
Runtime error

Correct Answer :   Runtime error

293 .
Which of these package is used for graphical user interface?
A)
java.applet
B)
java.awt
C)
java.awt.image
D)
java.io

Correct Answer :   java.awt

294 .
Which of this package is used for handling security related issues in a program?
A)
java.security
B)
java.lang.security
C)
java.awt.image
D)
java.io.security

Correct Answer :   java.security

295 .
What is the length of the application box made in the following Java program?
 
    import java.awt.*;
    import java.applet.*;
    public class myapplet extends Applet
    {
        Graphic g;
        g.drawString("A Simple Applet",20,20);    
    }
A)
20
B)
Default value
C)
Compilation Error
D)
Runtime Error

Correct Answer :   Compilation Error

296 .
Which of the following is the correct way of implementing an interface A by class B?
A)
class B extends A{}
B)
class B implements A{}
C)
class B imports A{}
D)
None of the above

Correct Answer :   class B implements A{}

297 .
What does an interface contain?
A)
Method definition
B)
Method declaration
C)
Method name
D)
Method declaration and definition

Correct Answer :   Method declaration

298 .
What will happen if we provide concrete implementation of method in interface?
A)
The concrete class implementing that method need not provide implementation of that method
B)
Runtime exception is thrown
C)
Method not found exception is thrown
D)
Compilation failure

Correct Answer :   Compilation failure

299 .
What happens when we access the same variable defined in two interfaces implemented by the same class?
A)
The interfaceName.variableName needs to be defined
B)
The JVM is not able to identify the correct variable
C)
Runtime Exception
D)
Compilation failure

Correct Answer :   The interfaceName.variableName needs to be defined

300 .
What should the return type of method where there is no return value?
A)
Null
B)
Empty collection
C)
Empty String
D)
Singleton collection

Correct Answer :   Empty collection

301 .
Which of the following is a best practice to measure time taken by a process for execution?
A)
System.currentTimeMillis()
B)
System.nanoTime()
C)
System.getCurrentTime()
D)
System.getProcessingTime()

Correct Answer :   System.nanoTime()

302 .
Which is better in terms of performance for iterating an array?
A)
for(int i=99; i>=0; i–)
B)
for(int i=0; i<100; i++)
C)
for(int i=99; i>0; i++)
D)
for(int i=100; i<0; i++)

Correct Answer :   for(int i=99; i>=0; i–)

303 .
JUnits are used for which type of testing?
A)
Unit Testing
B)
Integration Testing
C)
System Testing
D)
Blackbox Testing

Correct Answer :   Unit Testing

304 .
Which of the below is an incorrect annotation with respect to JUnits?
A)
@Test
B)
@AfterEach
C)
@Junit
D)
@BeforeClass

Correct Answer :   @Junit

305 .
What does assertSame() method use for assertion?
A)
equals() method
B)
isEqual() method
C)
compare() method
D)
==

Correct Answer :   ==

306 .
How can we simulate if then behavior in Junits?
A)
if{..} else{..}
B)
if(..){..} else{..}
C)
Mockito.when(…).thenReturn(…);
D)
Mockito.if(..).then(..);

Correct Answer :   Mockito.when(…).thenReturn(…);

307 .
Which of the following is not a core interface of Hibernate?
A)
Criteria
B)
Session
C)
Configuration
D)
SessionManagement

Correct Answer :   SessionManagement

308 .
Which of the following methods hits database always?
A)
get()
B)
load()
C)
loadDatabase()
D)
getDatabase()

Correct Answer :   get()

309 .
Which of the following is not an advantage of using Hibernate Query Language?
A)
Database independent
B)
Easy to write query
C)
Difficult to implement
D)
No need to learn SQL

Correct Answer :   Difficult to implement

310 .
Which of the following is not an advantage of Hibernate Criteria API?
A)
Allows to use aggregate functions
B)
Cannot order the result set
C)
Can add conditions while fetching results
D)
Allows to fetch only selected columns of result

Correct Answer :   Cannot order the result set

311 .
Which method can be used to check fileAccessiblity?
A)
isReadable(path)
B)
isWritable(path)
C)
isExecutable(path)
D)
isReadable(path), isWritable(path), and isExecutable(path)

Correct Answer :   isReadable(path), isWritable(path), and isExecutable(path)

312 .
How to copy the file from one location to other?
A)
Files.copy(source, target)
B)
source.copy(target)
C)
Path.copy(source, target)
D)
Files.createCopy(target)

Correct Answer :   Files.copy(source, target)

313 .
How can we create a symbolic link to file?
A)
createLink()
B)
createTempLink()
C)
createSymbolicLink()
D)
createSymLink()

Correct Answer :   createSymbolicLink()

314 .
What are generic methods?
A)
Generic methods are the methods defined in a generic class
B)
Generic methods are the methods that extend generic class methods
C)
Generic methods are methods that take void parameters
D)
Generic methods are methods that introduce their own type parameters

Correct Answer :   Generic methods are methods that introduce their own type parameters

315 .
Which of these is an correct way of defining generic method?
A)
class <T1, T2, …, Tn> name[T1, T2, …, Tn] { /* … */ }
B)
public <T1, T2, …, Tn> name<T1, T2, …, Tn> { /* … */ }
C)
<T1, T2, …, Tn> name(T1, T2, …, Tn) { /* … */ }
D)
<T1, T2, …, Tn> name{T1, T2, …, Tn} { /* … */ }

Correct Answer :   public <T1, T2, …, Tn> name<T1, T2, …, Tn> { /* … */ }

316 .
Which of the following allows us to call generic methods as a normal method?
A)
Type Interface
B)
Interface
C)
Inner class
D)
All of the mentioned

Correct Answer :   Type Interface

317 .
What is use of wildcards?
A)
It is used to make code more readable
B)
It is used in cases when type being operated upon is not known
C)
It is used to access members of super class
D)
It is used for type argument of generic method

Correct Answer :   It is used in cases when type being operated upon is not known

318 .
Which of these is an correct way making a list that is upper bounded by class Number?
A)
List<? extends Number>
B)
List<extends ? Number>
C)
List(? extends Number)
D)
List(? UpperBounds Number)

Correct Answer :   List<? extends Number>

319 .
What will be the output of the following Java program?
 
    import java.util.*;
    class Output 
    {
        public static double sumOfList(List<? extends Number> list)
        {
            double s = 0.0;
            for (Number n : list)
                s += n.doubleValue();
            return s;
        }
        public static void main(String args[]) 
        {
           List<Double> ld = Arrays.asList(1.2, 2.3, 3.5);
           System.out.println(sumOfList(ld));
        }
    }
A)
5.0
B)
6.0
C)
7.0
D)
8.0

Correct Answer :   7.0

320 .
Which of the following is not true about Java beans?
A)
Extends java.io.Serializable class
B)
Provides no argument constructor
C)
Implements java.io.Serializable interface
D)
Provides setter and getter methods for its properties

Correct Answer :   Extends java.io.Serializable class

321 .
Which of the following is correct error when loading JAR file with duplicate name?
A)
java.io.NullPointerException
B)
java.lang.ClassNotFound
C)
java.lang.ClassFormatError
D)
java.lang.DuplicateClassError

Correct Answer :   java.lang.ClassFormatError

322 .
Which attribute is used to specify destroy method?
A)
destroy
B)
destroy-method
C)
destruction
D)
destruction-method

Correct Answer :   destroy-method

323 .
Which of the following is advantage of using PreparedStatement in Java?
A)
Prevents SQL injection
B)
Slow performance
C)
Encourages SQL injection
D)
More memory usage

Correct Answer :   Prevents SQL injection

324 .
Which one of the following contains date information?
A)
java.io.Time
B)
java.io.TimeStamp
C)
java.sql.Time
D)
java.sql.TimeStamp

Correct Answer :   java.sql.TimeStamp

325 .
Which of the following is used to limit the number of rows returned?
A)
setMaxRows(int i)
B)
setMinRows(int i)
C)
getMaxrows(int i)
D)
getMinRows(int i)

Correct Answer :   setMaxRows(int i)

326 .
Which of the following is not a JDBC connection isolation levels?
A)
TRANSACTION_REPEATABLE_READ
B)
TRANSACTION_NONREPEATABLE_READ
C)
TRANSACTION_READ_COMMITTED
D)
TRANSACTION_NONE

Correct Answer :   TRANSACTION_NONREPEATABLE_READ

327 .
How can we move from one desired step to another step?
A)
breakpoints
B)
logger.log
C)
System.out.println
D)
logger.error

Correct Answer :   breakpoints

328 .
What is debugging an application which runs on another java virtual machine on another machine?
A)
virtual debugging
B)
machine debugging
C)
remote debugging
D)
compiling debugging

Correct Answer :   remote debugging

329 .
How does eclipse provide the capability for debugging browser actions?
A)
internal web browser
B)
chrome web browser
C)
firefox web browser
D)
internet explorer browser

Correct Answer :   internal web browser

330 .
Servlet are used to program which component in a web application?
A)
client
B)
applet
C)
tomcat
D)
server

Correct Answer :   server

331 .
How can we connect to database in a web application?
A)
mysql
B)
oracle sql developer
C)
JDBC template
D)
toad

Correct Answer :   JDBC template

332 .
What does MIME stand for?
A)
Multipurpose Internet Messaging Extension
B)
Multipurpose Internet Messaging Extension
C)
Multipurpose Internet Media Extension
D)
Multipurpose Internet Mass Extension

Correct Answer :   Multipurpose Internet Messaging Extension

333 .
How does applet and servlet communicate?
A)
HTTP
B)
HTTPS
C)
FTP
D)
HTTP Tunneling

Correct Answer :   HTTP Tunneling

334 .
What happens if ServerSocket is not able to listen on the specified port?
A)
PortOccupiedException is thrown
B)
The system will wait till port is free
C)
IOException is thrown when opening the socket
D)
The system exits gracefully with appropriate message

Correct Answer :   IOException is thrown when opening the socket

335 .
What does bind() method of ServerSocket offer?
A)
binds the port to the JVM
B)
binds the server socket to the JVM
C)
binds the serversocket to a specific address (IP Address and port)
D)
binds the server and client browser

Correct Answer :   binds the serversocket to a specific address (IP Address and port)

336 .
What happens if IP Address of host cannot be determined?
A)
UnknownHostException is thrown
B)
The system exit with no message
C)
Temporary IP Address is assigned
D)
IOException is thrown

Correct Answer :   UnknownHostException is thrown

337 .
What is the java method for ping?
A)
ping()
B)
isReachable()
C)
portBusy()
D)
hostReachable()

Correct Answer :   isReachable()

338 .
How constructor can be used for a servlet?
A)
Initialization
B)
Constructor function
C)
Setup() method
D)
Initialization and Constructor function

Correct Answer :   Initialization and Constructor function

339 .
Which of the following code is used to get an attribute in a HTTP Session object in servlets?
A)
session.getAttribute(String name)
B)
session.alterAttribute(String name)
C)
session.updateAttribute(String name)
D)
session.setAttribute(String name)

Correct Answer :   session.getAttribute(String name)

340 .
When destroy() method of a filter is called?
A)
The destroy() method is called after the filter has executed doFilter method
B)
The destroy() method is called only once at the end of the life cycle of a filter
C)
The destroyer() method is called after the filter has executed
D)
The destroy() method is called only once at the begining of the life cycle of a filter

Correct Answer :   The destroy() method is called only once at the end of the life cycle of a filter

341 .
Which of the following is used for session migration?
A)
Persisting the session in database
B)
Create new database connection
C)
Kill session from multiple sessions
D)
URL rewriting

Correct Answer :   Persisting the session in database

342 .
Which of the following is not true about session?
A)
All users connect to the same session
B)
All users have same session variable
C)
New session cannot be created for a new user
D)
Default timeout value for session variable is 20 minutes

Correct Answer :   Default timeout value for session variable is 20 minutes

343 .
Which method creates unique fields in the HTML which are not shown to the user?
A)
URL writing
B)
User authentication
C)
HTML Hidden field
D)
HTML invisible field

Correct Answer :   HTML Hidden field

344 .
Which one of the following is correct for directive in JSP?
A)
<%@directive%>
B)
<%!directive%>
C)
<%=directive%>
D)
<%directive%>

Correct Answer :   <%@directive%>

345 .
What temporarily redirects response to the browser?
A)
<%@directive%>
B)
<jsp:forward>
C)
response.sendRedirect(URL)
D)
response.setRedirect(URL)

Correct Answer :   response.sendRedirect(URL)

346 .
What is not the advantage of Reflection?
A)
Construct an object for a class at runtime
B)
Examine an object’s class at runtime
C)
Examine a class’s field and method at runtime
D)
Examine a class’s field at compile time

Correct Answer :   Examine a class’s field at compile time

347 .
How to get the class object of associated class using Reflection?
A)
Class.forName(“className”)
B)
className.getClassName()
C)
Class.name(“className”)
D)
className.getClass()

Correct Answer :   Class.forName(“className”)

348 .
Which file is used to define dependency in maven?
A)
build.xml
B)
pom.xml
C)
version.xml
D)
dependency.xml

Correct Answer :   pom.xml

349 .
Which environment variable is used to specify the path to maven?
A)
PATH
B)
MAVEN_HOME
C)
JAVA_HOME
D)
CLASSPATH

Correct Answer :   MAVEN_HOME

350 .
Which command can be used to check maven version?
A)
mvn -ver
B)
maven -ver
C)
maven -version
D)
mvn -version

Correct Answer :   mvn -version