wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Oracle Java Certification Test-1

Total questions: 200

Worksheet time: 3hrs 46mins

Name
Class
Date
1.

What would the new value of A be?

A=1;

a++;

a)

1

b)

2

c)

3

d)

4

2.

What's the value of below?


int i=5;

System.out.println(i++);

System.out.println(i);

System.out.println(++i);

a)

5

6

7

b)

6

6

7

c)

6

7

8

d)

5

5

6

3.

Which statement(s) are equivalent to i = i + 1?

a)

i += 1

b)

i++

c)

i -= 1

d)

i--

4.

Which are the types of operators seen? Select as many you think

a)

bitwise operator

b)

subtraction operator

c)

equality operator

d)

arithmetic operator

5.

what is modulo operation used for ?

a)

performs division

b)

performs division and gives no remainder

c)

performs division and gives remainder

d)

does not perform division

6.

arithmetic operators return a value. True or false?

a)

true

b)

false

7.

conditional operators does not return a value

a)

true

b)

false

8.

which data types work on bitwise operators?

a)

byte

b)

double

c)

char

d)

int

9.

which type of operator it is? i + =5

a)

addition assignment operator

b)

conditional operator

c)

arithmetic operator

d)

equality operator

10.

Find the output for the following.

public class IncDec

{

public static void main(String s[])

{

int a = 1;

int b = 2;

int c;

int d;


c = ++b;

d = a++;


c++;


System.out.println("a = " + a);

System.out.print("b = " + b);

System.out.println("c = " + c);

System.out.print("d = " + d);

}

}

a)

a = 2 b = 3 c = 4 d = 1

b)

a = 2 b = 3 c = 4 d = 1

c)

Program does not compile.

d)

a = 1 b = 2 c = 4 d = 2

11.

What will be the output of the program?

class Test

{

public static void main(String [] args)

{

int x=20;

String sup = (x < 15) ? "small" : (x < 22)? "tiny" : "huge";

System.out.println(sup);

}

}

a)

small

b)

tiny

c)

huge

d)

Compilation fails

12.

Find the output of the following snippet.


class Numbers

{

public static void main(String args[])

{

int a=20, b=10;

if((a<b)&&(b++ <25))

{

System.out.println("this is any language logic");

}

System.out.println(b);

}

}

a)

10

b)

12

c)

11

d)

Compilation Error

13.

Please write correct output in following space-

a)

10

b)

20

c)

No Output

d)

Error

14.

1. Which of this method is given parameter via command line arguments?

a)

a) main()

b)

b) recursive() method

c)

c) Any method

d)

d) System defined methods

15.

What are the Type Conversions available in Java language?

a)

A) Narrowing Type Conversion

b)

B) Widening Type Conversion

c)

A and B

d)

D) None of the above

16.

What is the output of the below Java code snippet?

char ch = 'A';//ASCII 65

int a = ch + 1;

ch = (char)a;

System.out.println(ch);

a)

A) 66

b)

B) A

c)

C) B

d)

D) 65

17.

Which type of loop is best known for its boolean condition that controls entry to the loop?

a)

A. do-while loop

b)

B. for (traditional)

c)

C. for-each

d)

D. while

18.

What will be the Output of the below code:

public class Demo{

public static void main(String[] arr){

}

public static void main(String arr){

}

}

a)

a) Nothing

b)

b) Error

c)

C) Finite

d)

d) Hii

19.

char is 2 byte in storage?

a)

True

b)

False

20.

Name the data type: '3'

a)

int

b)

char

c)

String

d)

None of the above

21.

What data type would you use for storing the number of students in a class?

a)

boolean

b)

String

c)

double

d)

int

22.
What data type would be best used to record an email address?
a)
String
b)
Integer
c)
Real
d)
Character
23.

What is the output of the below Java code snippet?

char ch = 'A';//ASCII 65

int a = ch + 1;

ch = (char)a;

System.out.println(ch);

a)

A) 66

b)

B) A

c)

C) B

d)

D) 65

24.

What is the output of the following code snippet?

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

{ }

System.out.println(i);

a)

A. 5

b)

B. 0

c)

C. 4

d)

D. Compilation Error

25.

Function of the Scanner class to accept a float literal from the user is

a)

nextInt( )

b)

hasNext( )

c)

next( )

d)

nextFloat( )

26.

Predict the value of k,

int k =10;

k=k+k++;

a)

11

b)

20

c)

21

d)

22

27.
Which of these is not a Thread state?
a)
New
b)
Runnable
c)
sleep
d)
terminated
28.

Which of the following key word is optional in Exception handling program

a)

try

b)

catch

c)

finally

d)

throw

29.

What is an exception

a)

Error occurred during the execution of a program

b)

Bug occurred during the compile time of a program

c)

Simply an Error

d)

It is related to input values

30.

Exception classes belongs to following package

a)

import java.io.*

b)

import java.lang.*

c)

import java.util.*

d)

import java.lang.Exception.*

31.

Choose an exception if attempt to divide number by zero


int number = 89 / 0;

System.out.println("The answer is " + number);

a)

ArithmeticException

b)

NullPointerException

c)

NumberFormatException

d)

ArrayIndexOutOfBoundException

32.

class exception_handling

{ public static void main(String args[])

{ try

{ int a, b;

b = 0;

a = 5 / b;

System.out.print("A");

} catch(ArithmeticException e)

{ System.out.print("B");

}

finally

{ System.out.print("C");

}

}

}

a)

A

b)

B

c)

AC

d)

BC

33.

Find the output for the following.

public class IncDec

{

public static void main(String s[])

{

int a = 1;

int b = 2;

int c;

int d;


c = ++b;

d = a++;


c++;


System.out.println("a = " + a);

System.out.print("b = " + b);

System.out.println("c = " + c);

System.out.print("d = " + d);

}

}

a)

a = 2 b = 3 c = 4 d = 1

b)

a = 2 b = 3 c = 4 d = 1

c)

Program does not compile.

d)

a = 1 b = 2 c = 4 d = 2

34.
_________________ is a collection of elements used to store the same type of data.
a)
Array
b)
Switch
c)
Case
d)
Loop
35.
What are the legal indexes for the array ar, given the following declaration:
int[] ar = {2, 4, 6, 8 }
a)
 0, 1, 2, 3
b)
 1, 2, 3, 4
c)
2, 4, 6, 8
d)
 0, 2, 4, 6
36.

What is the first index of an array?

a)

1

b)

0

c)

2

d)

3

37.

For the array:

int stats[3];

What is the range of the index?

a)

0 to 3

b)

0 to 2

c)

1 to 3

d)

0 to 4

38.

int [] nums = {2, 3, 5, 8, 9, 11};

How would you access the fourth element in nums?

a)

nums[4]

b)

nums[3]

c)

nums(4)

d)

nums(3)

39.
The first value of an array called quizzes can be accessed with which of the following statements?
a)
quizzes[1] = 100;
b)
quizzes[0] = 100;
c)
quizzes[zero] = 100;
d)
quizzes[one] = 100;
40.
Which of the following statements outputs the fifth value in the quizzes array?
a)
System.out.println(quizzes[5]);
b)
quizzes[4];
c)
quizzes[5];
d)
System.out.println(quizzes[4]);
41.
Index values of an array range from ______________.
a)
0 to length – 1
b)
1 to length
c)
0 to length
d)
0 to length + 1
42.
Create an array of 12 strings called months.
a)
String[] months = new String[12];
b)
String months = new String[12];
c)
String[] months = new String[];
d)
String[12] months = new String[];
43.
Given the following method, what would test return if
a = {0, 2, 3, 4} and v = 1?
a)
-1
b)
0
c)
1
d)
2
44.
What value is at index 1 in this array?  String[] names = {"Mack", "Dennis", "Dee", "Charlie"};
a)
Mack
b)
Dennis
c)
Dee
d)
Charlie
45.
True or False:  An array can be store different types of data (like store both doubles and ints).
a)
True
b)
False
46.
What is the correct way to create an array with these three numbers: 12  8  15
a)
int[] = {12, 8, 15};
b)
int[] nums = {12  8  15};
c)
int[] nums = {12, 8, 15}
d)
int[] nums = {12, 8, 15};
47.

Find the output

class Test {

public static void main(String args[]) {

int arr[2];

System.out.println(arr[0]);

System.out.println(arr[1]);

}

}

a)

Compile error

b)

Exception

c)

Garbage Value

Garbage Value

d)

0

0

48.

Is String a primitive data type?

a)

Yes

b)

No

c)

Both

49.

Java is a

a)

Procedure Oriented Language

b)

Structure Oriented Language

c)

Object_Oriented Language

d)

Machine Language

50.

The name of the following should be the file name in Java

a)

Object Name

b)

Variable Nam

c)

Class Name

d)

Array Name

51.

Java program is

a)

Interpreted

b)

Compiled

52.

Java program does not run without below function

a)

user()

b)

system()

c)

main()

d)

void()

53.

A ___________ file is created after successful compilation of a Java program.

a)

Object file

b)

Array file

c)

Class file

d)

String file

54.

Command to compile Java program

a)

javax

b)

javay

c)

javac

d)

Java

55.

Command to run a Java program

a)

javaa

b)

java

c)

jaava

d)

jaavaa

56.

JDK stands for

a)

Java Developer Kit

b)

Java Development Kit

c)

Java Design Kit

d)

Java Debugging Kit

57.

JRE stands for

a)

Java Run Environment

b)

Java Run Execution

c)

Java Runtime Environment

d)

Java Ready Execution

58.

Java is

a)

Machine dependent language

b)

Machine independent language

59.

Is String a primitive data type?

a)

Yes

b)

No

c)

Both

60.

Which method to use to find length of a string?

a)

length()

b)

size()

c)

long()

d)

count()

61.

Which data type gets returned from length() method in String class?

a)

double

b)

String

c)

int

d)

number

62.

String txt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";


What is the correct way to find the length of "txt" string?

a)

int len = length(txt);

b)

float len = txt.length();

c)

int len = txt.length();

d)

double len = length(txt);

63.

Which is correct method to convert String into uppercase

a)

changeUpperCase()

b)

convertUpperCase()

c)

toUpper()

d)

toUpperCase()

64.

String txt = "Hello World";

System.out.println(txt.toUpperCase());


Choose the correct output.

a)

"HELLO WORLD"

b)

HELLO WORLD

c)

Hello world

d)

Hello World

65.

Choose correct purpose of indexOf() in String class.

a)

returns the index (the position) of the last occurrence of a specified text in a string

b)

returns the character of the first occurrence of a specified character in a string

c)

returns the index (the position) of the first occurrence of a specified text in a string (excluding whitespace)

d)

returns the index (the position) of the first occurrence of a specified text in a string (including whitespace)

66.

String x = "10";

String y = "20";

String z = x + y;

System.out.println(z);

Guess the output.

a)

1020

b)

10 20

c)

30

d)

"10 20"

67.

What will be the output of below code?


String statement = "Outfit of the day";

System.out.println(statement.Substring(3,6));

a)

it of

b)

tfit

c)

fit

d)

FIT

68.

Choose most appropriate purpose of trim() method in String?

a)

to remove white spaces

b)

to get a substring of the string

c)

to cut String at desired index

d)

to remove extra white spaces from start and end of String

69.

What is the return type of equalsIgnorecase() method?

a)

int

b)

String

c)

char

d)

boolean

70.

What is the most appropriate way to check if two Strings are identical?

a)

string1 == string2

b)

string1.equals(string2)

c)

string1.same(string2)

d)

string1.equalsIgnorecase(string2)

71.

(Multiple answer question)

Pick all NON-primitive datatypes from below :

a)

String

b)

int

c)

primitive

d)

Array

72.

What is the correct relation between length and last-index of array?

a)

last-index is always 1 more than the length

b)

last-index is 1 less than the length (but not always)

c)

last-index is always 1 less than the length

d)

last-index is always equal to the length

73.
String word = "A few good men";
What is word.length()?
a)
14
b)
15
c)
13
74.
String word = "A few good men";
What is word.charAt(7) ?
a)
o
b)
g
c)
7
d)
good men
75.
String word = "A few good men";
What is word.startsWith("A few") ?
a)
true
b)
false
76.
String word = "A few good men";
What is word.endsWith("man") ?
a)
true
b)
false
77.

String word = "A few good men";

What is word.indexOf(“f”)?

a)

2

b)

0

c)

1

d)

3

78.
String word = "A few good men";
What is word.substring(3, 7) ?
a)
ew g
b)
ew go
c)
few
d)
few[space]
79.
String word = "A few good men";
What is word.length()?
a)
14
b)
15
c)
13
80.
String word = "A few good men";
What is word.charAt(7) ?
a)
o
b)
g
c)
7
d)
good men
81.
String word = "A few good men";
What is word.indexOf(“f”)?
a)
2
b)
0
c)
1
d)
-1
82.
String word = "A few good men";
What is word.indexOf(“f”)?
a)
2
b)
0
c)
1
d)
-1
83.
String word = "A few good men";
What is word.indexOf(“bad”)?
a)
0
b)
-1
c)
3
84.
String word = "A few good men";
What is word.substring(3, 7) ?
a)
ew g
b)
ew go
c)
few
d)
few[space]
85.

Which of the following is NOT a primitive data type?

a)

double

b)

float

c)

boolean

d)

String

86.

What would be output by the following program segment?


String n1 = "Samuel";

String n2 = "Samantha";


System.out.print(n1.compareTo(n2);

a)

false

b)

true

c)

a positive number, 20

d)

a negative number, -20

87.

String txt = "Hello World";

System.out.println(txt.toUpperCase());


Choose the correct output.

a)

"HELLO WORLD"

b)

HELLO WORLD

c)

Hello world

d)

Hello World

88.

String firstName = "John ";

String lastName = "Doe";

System.out.println(firstName.concat(lastName));


Guess the output.

a)

John.concat(Doe)

b)

John Doe

c)

JohnDoe

d)

"John Doe"

89.

String x = "10";

String y = "20";

String z = x + y;


Guess the output.

a)

1020

b)

10 20

c)

30

d)

"10 20"

90.

Which of these class is superclass of String and StringBuffer class?

a)

java.util

b)

java.lang

c)

ArrayList

d)

None of the mentioned

91.

Which of these is an incorrect statement?

a)

String objects are immutable, they cannot be changed

b)

String object can point to some other reference of String variable

c)

StringBuffer class is used to store string in a buffer for later use

d)

None of the mentioned

92.

What is the output of this 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

93.

What is the output of following program?

class string_class{

public static void main(String args[]){

String obj = "hello";

String obj1 = "world";

String obj2 = obj;

obj2 = " world";

System.out.println(obj + " " + obj2);

}

}

a)

hello hello

b)

world world

c)

hello world

d)

world hello

94.

The String method compareTo() returns

a)

true

b)

false

c)

an int value

d)

1

95.

What is the output of the following code?

String a = "19";

String b = "75";

System.out.println(a+" "+b);

a)

19 75

b)

94

c)

Compilation Error

d)

1975

96.

What method of class String is used to remove white spaces at the beginning and end of String objects?

a)

remove()

b)

trim()

c)

concat()

d)

Substring()

97.

What is the return type of equalsIgnorecase() method?

a)

int

b)

String

c)

char

d)

boolean

98.

What is the output of the following?

String a = "I will pass the exams.";

String b = " I will pass the exams. ";

if (a.equals(b))

System.out.println("fail");

else

System.out.println(b.substring(9,12));

a)

pass

b)

fail

c)

Compilation Error

d)

I will pass the exams.

99.

Which of these class is superclass of String and StringBuffer class?

a)

java.util

b)

java.lang

c)

ArrayList

d)

None of the mentioned

100.

String name = "Mark Hayes";

String team = "Yankees";

String enemy = "Red Sox";

String funny = "Yankees will win the World Series!";

String yearsWon = "2009 2000 1999 1998 1996";


System.out.println( team.substring(2, 7) );

(a)  

101.
Which of the following statements are valid, given the mystery function definition below?
static int mystery(String p1)
a)
All of these are valid
b)
mystery("data");
c)
int result = mystery("data");
d)
if (mystery("data") == 3)
102.
What will be the output of the following for() loop:
String target = "millisecond";
for (int i=0; i<target.length(); i++)
{
if (target.charAt(i) == 'l')
break;
else
System.out.print(target.charAt(i));
}
 
a)
m
b)
mi
c)
millisecond
d)
miisecond
103.

What does the following print?

String str = "And yet, it moves!"

System.out.println( str.charAt( str.length() ) );

a)

A

b)

n

c)

!

d)

The statment is incorrect.

104.

Examine the following fragment:

String world = "World!";

StringBuffer buf = new StringBuffer( "Hello" );


buf.append(' ');

buf.append( world );

How many StringBuffer objects are constructed?

a)

0

b)

1

c)

2

d)

3

105.

After a StringBuffer has been constructed, how many characters may be added to it?

a)

No more after it has been constructed.

b)

Only as many as the original capacity.

c)

As many as needed; it will grow in size if necessary.

d)

A new StringBuffer must be constructed each time characters are added.

106.

You wish to compare the contents of two StringBuffer objects. How should this be done?

a)

Use the == operator.

b)

Use the equals() method of StringBuffer.

c)

Construct a String object from each StringBuffer and use their equals() method.

d)

Do a character-by-character comparison using charAt() and ==.

107.
Why don't we have to save the result of the append() method of Stringbuffer in a variable?
a)
It changes the Stringbuffer instance on which the method is called on.
b)
There is only one variable of type Stringbuffer, so Java knows where to save the result
c)
Java Magic
108.
If a String personName = "Carlos", what's the return of personName.indexOf( 'z' )?
a)
5
b)
Carl
c)
-1
d)
Does not return a int
109.

Examine the following fragment:

String cat = "Hello"


cat += " ";

cat += "World" ;

How many objects are constructed?

a)

0

b)

1

c)

2

d)

3

110.

What is the advantage of Exception Handling

a)

To avoid abnormal termination of a program

b)

To find out errors

c)

To Debug program

d)

None of these

111.

What is the parent class of All Exceptions in JAVA

a)

Throw

b)

Exception

c)

Error

d)

Bug

112.

Which of the following key word is optional in Exception handling program

a)

try

b)

catch

c)

finally

d)

throw

113.

try block may or may not contains catch blocks

a)

True

b)

False

114.

What is the purpose of 'throw' keyword

a)

To Raise an exception explicityly

b)

To Raise an exception implicityly

c)

To create user defined exceptions

d)

To create custom exceptions

115.

What is an exception

a)

Error occurred during the execution of a program

b)

Bug occurred during the compile time of a program

c)

Simply an Error

d)

It is related to input values

116.

How to create our own exception

a)

using 'throw' keyword

b)

using 'throws' keyword

c)

using 'finally' keyword

d)

using 'throwable' keyword

117.

Exception classes belongs to following package

a)

import java.io.*

b)

import java.lang.*

c)

import java.util.*

d)

import java.lang.Exception.*

118.

Which of these keywords is not a part of exception handling?

a)

try

b)

finally

c)

thrown

d)

catch

119.

java.lang.NullPointerException is a

a)

Error

b)

runtime exception

c)

Compile time exception

d)

None

120.

Which of these class is highest in hierarchy in java

a)

java.lang.Exception

b)

java.lang.Error

c)

java.lang.Throwable

d)

java.lang.Object

121.

Choose the CORRECT exception


String department="JTMK";

Integer no=Integer.parseInt(department);

a)

ArithmeticException

b)

NullPointerException

c)

NumberFormatException

d)

ArrayIndexOutOfBoundsException

122.

Choose an exception if attempt to divide number by zero


int number = 89 / 0;

System.out.println("The answer is " + number);

a)

ArithmeticException

b)

NullPointerException

c)

NumberFormatException

d)

ArrayIndexOutOfBoundException

123.

What will it print?

a)

1

2

3

30

b)

1

2

30

c)

1

2

3

11

d)

1

2

11

124.

Which line or lines should we get inside a try block to avoid errors?

a)

3

b)

4

c)

6

d)

2

125.

What will this print?

a)

There was an error

b)

1

c)

9

d)

0

126.

What will this program print?

a)

Nothing, there is an error

b)

There was a ValueError, please try again

c)

num1num2num1^{num2}

d)

num2num1num2^{num1}

127.

public class Foo

{

public static void main(String[] args)

{

try

{

return;

}

finally

{

System.out.println( "Finally" );

}

}

}

a)

Finally

b)

Compilation fails.

c)

The code runs with no output

d)

An exception is thrown at runtime.

128.

What will be the output of the program?

try

{

int x = 0;

int y = 5 / x;

}

catch (Exception e)

{

System.out.println("Exception");

}

catch (ArithmeticException ae)

{

System.out.println(" Arithmetic Exception");

}

System.out.println("finished");

a)

finished

b)

runtime error.

c)

Compilation fails

d)

Exception.

129.

public class X

{

public static void main(String [] args)

{

try

{

badMethod();

System.out.print("A");

}

catch (Exception ex)

{

System.out.print("B");

}

finally

{

System.out.print("C");

}

System.out.print("D");

}

public static void badMethod()

{

throw new Error(); /* Line 22 */

}

}

a)

ABCD

b)

Compilation fails.

c)

C is printed before exiting with an error message.

d)

BC is printed before exiting with an error message

130.

public class X

{

public static void main(String [] args)

{

try

{

badMethod();

System.out.print("A");

}

catch (RuntimeException ex) /* Line 10 */

{

System.out.print("B");

}

catch (Exception ex1)

{

System.out.print("C");

}

finally

{

System.out.print("D");

}

System.out.print("E");

}

public static void badMethod()

{

throw new RuntimeException();

}

}

a)

BD

b)

BDE

c)

BD

d)

DE

131.

FileNotFoundException

a)

Is a subclass/extends IOException

b)

Is a Compile time exception

c)

Found in java.io package

d)

All

132.

class Main {

public static void main(String args[]) {

try {

throw 10;

}

catch(int e) {

System.out.println("Got the Exception " + e);

}

}

}

a)

Got the Exception 10

b)

Got the Exception 0

c)

Compiler Error

d)

none

133.

class exception_handling

{ public static void main(String args[])

{ try

{ int a, b;

b = 0;

a = 5 / b;

System.out.print("A");

} catch(ArithmeticException e)

{ System.out.print("B");

}

finally

{ System.out.print("C");

}

}

}

a)

A

b)

B

c)

AC

d)

BC

134.

class IT

{

static public void main(String...args)

{

int k=Integer.parseInt(args[0]);

System.out.println(k);

}

}

if args[0]="gec" then what type of exception is thrown by the above program.

a)

NumberFormatException

b)

NullPointerException

c)

ArrayIndexOutOfBoundsException

d)

InvalidStringException

135.

class IT

{

static public void main(String...args)

{

String s=null;

System.out.println("length is:"+s.length());

}

}

a)

It throws NullPointerException

b)

it throws IOException

c)

It throws StringExeption

d)

output is 0

136.
a)

peep

b)

bark

c)

meow

d)

Compilation fails

e)

An exception is thrown at runtime.

137.
a)

Cat is-a Animal

b)

Cat is-a Jumper

c)

Dog is-a Animal

d)

Beagle has-a Tail

e)

Beagle has-a Jumper

138.
a)

public int blipvert(int x) { return 0; }

b)

private int blipvert(int x) { return 0; }

c)

private int blipvert(long x) { return 0; }

d)

protected long blipvert(int x) { return 0; }

e)

protected int blipvert(long x) { return 0; }

139.
a)

test

b)

null

c)

An exception is thrown at runtime.

d)

Compilation fails because of an error in line 1.

e)

Compilation fails because of an error in line 4.

140.
a)

Compilation fails.

b)

An exception is thrown at runtime.

c)

The attribute id in the Item object remains unchanged.

d)

The attribute id in the Item object is modified to the new value.

e)

A new Item object is created with the preferred value in the id attribute.

141.
a)

int foo() { /* more code here */ }

b)

void foo() { /* more code here */ }

c)

public void foo() { /* more code here */ }

d)

private void foo() { /* more code here */ }

e)

protected void foo() { /* more code here */ }

142.
a)

p0 = p1;

b)

p1 = p2;

c)

p2 = (ClassC)p4;

d)

p2 = (ClassC)p1;

e)

p1 = (ClassB)p3;

143.
a)

Value: 3

b)

Value: 8

c)

Value: 13

d)

Compilation fails.

e)

The code runs with no output.

144.

Which Man class properly represents the relationship "Man has a best friend who is a Dog"?

a)

class Man extends Dog { }

b)

class Man implements Dog { }

c)

class Man { private BestFriend dog; }

d)

class Man { private Dog bestFriend; }

e)

class Man { private Dog<bestFriend>; }

145.
a)

An exception is thrown at runtime.

b)

Compilation fails because of an error in line 7.

c)

Compilation fails because of an error in line 4.

d)

Compilation succeeds and no runtime errors with class A occur.

146.

Properties of an OOPS are also known __________________ of JAVA Programming

a)

methods

b)

Characteristics

c)

classes

d)

functions

147.

Which of the following concepts of OOPs means exposing only necessary information and hiding the background details?

a)

Encapsulation

b)

Abstraction

c)

Data hiding

d)

Data binding

148.

As blueprint is a design for a house, a class is a design for a(n):

a)

object

b)

variable

c)

constant

d)

statement

149.
These have identitystate, and behavior.
a)
class
b)
object
c)
method
d)
void
150.

Which one is NOT the principle of OOP?

a)

Class

b)

Abstraction

c)

BlueJ

d)

Abstraction

e)

Encapsulation

151.
The wrapping up of data and functions into a single unit is called
a)
overloading
b)
class
c)
object
d)
encapsulation 
152.

In OOP the main importance is given to the

a)

methods

b)

procdures

c)

data

d)

objects

153.

Java uses both compiler and interpreter

a)

true

b)

false

154.

The system of using the existing class in another class is called

a)

encapsulation

b)

abstraction

c)

Inheritance

d)

abstraction

155.

Java was developed by

a)

James gosling

b)

John gosling

c)

James frank

d)

John frank

156.
a)

A

b)

B

c)

C

d)

D

e)

E

157.
a)

A

b)

B

c)

C

d)

D

158.
a)

A

b)

B

c)

C

d)

D

159.
a)

A

b)

B

c)

C

d)

D

160.
a)

A

b)

B

c)

C

d)

D

161.
a)

A

b)

B

c)

C

d)

D

162.
a)

A

b)

B

c)

C

d)

D

163.

a)

A

b)

B

c)

C

d)

D

e)

E

164.
a)

A

b)

B

c)

C

d)

D

165.
a)

A

b)

B

c)

C

d)

D

166.
a)

A

b)

B

c)

C

d)

D

167.
a)

A

b)

B

c)

C

d)

D

168.
a)

A

b)

B

c)

C

d)

D

169.
a)

A

b)

B

c)

C

d)

D

170.
a)

A

b)

B

c)

C

d)

D

171.
a)

A

b)

B

c)

C

d)

D

172.
a)

A

b)

B

c)

C

d)

D

e)

E

173.
a)

A

b)

B

c)

C

d)

D

e)

F

174.
a)

A

b)

B

c)

C

d)

D

e)

E

175.
a)

A

b)

B

c)

C

d)

D

176.
a)

A

b)

B

c)

C

d)

D

177.
a)

A

b)

B

c)

C

d)

D

178.
a)

A

b)

B

c)

C

d)

D

179.

a)

A

b)

B

c)

C

d)

D

180.

a)

A

b)

B

c)

C

d)

D

181.

Which of the following is a type of polymorphism in Java?

a)

Compile time polymorphism

b)

Execution time polymorphism

c)

Multiple polymorphism

d)

Multilevel polymorphism

182.

Which component is used to compile, debug and execute java program?

a)

JVM

b)

JDK

c)

JIT

d)

JRE

183.

Syntax to compile java program from command prompt

a)

java Filename.java

b)

javac Filename

c)

javac Filename.java

d)

java Filename

184.

Which component is responsible for converting bytecode into machine specific code?

a)

JVM

b)

JDK

c)

JIT

d)

JRE

185.

Which of the following is not a valid Java comment?

a)

/** Comment 1 */

b)

*/ Comment 2 /*

c)

// Comment 3

d)

/* Comment 4 */

186.

When saving a Java source file, save it with an extension of

a)

.java.

b)

.javac.

c)

.src.

d)

.class.

187.

Which of the following is not a rule that must be followed when naming identifiers?

a)

After the first character, you may use the letters a-z, A-Z, an underscore, a dollar sign, or digits 0-9.

b)

Identifiers can contain spaces.

c)

Uppercase and lowercase characters are distinct.

d)

The first character must be one of the letters a-z, A-Z, an underscore or a dollar sign.

188.

To print "Hello, world" on the monitor, use the following Java statement:

a)

System.out.println("Hello, world");

b)

System Print = "Hello, world";

c)

SystemOutPrintln('Hello, world');

d)

system.out.println{Hello, world};

189.

Which company owns Java?

a)

Oracle

b)

Microsoft

c)

Google

d)

Apple

e)

Intel

190.

Who invented Java?

a)

James Gosling

b)

Sergey Brin

c)

Steve Jobs

d)

Bill Gates

e)

Tim Berners-Lee

191.

Java was originally named:

a)

Coffee

b)

Oak

c)

New C++

d)

Duke

192.

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

a)

super

b)

this

c)

extend

d)

extends

193.

Which of these statement is incorrect?

a)

Every class must contain a main() method

b)

Applets do not require a main() method at all

c)

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

d)

main() method must be made public

194.

What is the extension of compiled java classes?

a)

.java

b)

.class

c)

.txt

d)

.js

195.
When we want to print in Java, we use the code ......
a)
system.out.print();
b)
System.out.println();
c)
System.Out.Printf();
d)
System.out.show();
196.

Where does a java program start executing instructions from:

a)

class

b)

source file

c)

main method

d)

object

197.

Which of these keywords is used to make a class?

a)

class

b)

struct

c)

int

d)

none of the mentioned

198.

Which of the following is a type of polymorphism in Java?

a)

Compile time polymorphism

b)

Execution time polymorphism

c)

Multiple polymorphism

d)

Multilevel polymorphism

199.

Which of the following is not OOPS concept in Java?

a)

Inheritance

b)

Encapsulation

c)

Polymorphism

d)

Compilation

200.
Which type of data is used to enter the value ("Welcome")?
a)
Text
b)
Characters
c)
String
d)
Boolean