wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Java Advance review

Total questions: 109

Worksheet time: 1hrs 11mins

Name
Class
Date
1.

which one this keywords are used to create a class in java

a)

class

b)

struct

c)

int

d)

none of the avove

2.

which of this class is used by character streams for reading data from buffer

a)

BufferReader

b)

InputStreamReader

c)

FileReader

d)

FileInputStream

3.

superclass of all classes representing the output stream of characters is -------------

a)

OutputStream

b)

Reader

c)

InputStream

d)

Writer

4.

which interface needs to be implemented in order to make an object seralized

a)

clonnable

b)

remote

c)

seralizable

d)

none of the above

5.

Which one of the following statement is not true about the collection interface?

a)

all methods defined in set interface are also defined in collection interface

b)

list interface extends collection interface

c)

set interface extends collection interface

d)

all methods defined in list interface are also defined in collection interface

6.

which one of the following is true?

a)

runnable interface declares the start method

b)

Thread.start() method is used to move a thread from a new state to the runnable state

c)

Thread.runnable() method is used to move a thread from new state to the runnable state

d)

Thread.run() method is used to move a thread from new state to the runnable state

7.

which one of the following have elements in insertion order

a)

sorted map

b)

hashmap

c)

linkedhashmap

d)

treemap

8.
Which type of data is used to enter the value ("Welcome")?
a)
Text
b)
Characters
c)
String
d)
Boolean
9.
Which type of data is used to enter the value (1234.5)?
a)
Integer
b)
Double 
c)
Char
d)
Void
10.
Which type of data is used to enter the value (True)?
a)
Float
b)
Boolean
c)
Check box
d)
ٍString
11.
We are use Scanner Library in java for...
a)
Give permissions to the user
b)
Correcting software errors
c)
Allows user to read data
d)
Allows the user to enter data
12.
We are use Random Library in java for...
a)
Choose a set of random numbers
b)
Deploy the program randomly
c)
Store a set of information at random
d)
All answers are correct
13.
We are use For loop ..........
a)
To repeat a specified number of operations.
b)
To repeat a unspecified number of operations.
c)
All answers are correct
14.
We are use While loop ..........
a)
To repeat a specified number of operations.
b)
To repeat a unspecified number of operations.
c)
All answers are correct
15.
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();
16.
A variable that holds a whole number
a)
String
b)
boolean
c)
int
d)
float
17.

How would you declare a variable storing a person's name?

a)

string name = "Elroy";

b)

name String = "Elroy";

c)

String name = Elroy;

d)

String name = "Elroy";

e)

Me llamo Elroy

18.

List all parameters that exist in this program segment:-

a)

double point, String student

b)

point, student

c)

name, mark

d)

name[i], mark[i]

19.

What is the first index of an array?

a)

1

b)

0

c)

2

d)

3

20.

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

21.

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)

22.
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;
23.
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]);
24.
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
25.
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[];
26.
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
27.
What value is at index 1 in this array?  String[] names = {"Mack", "Dennis", "Dee", "Charlie"};
a)
Mack
b)
Dennis
c)
Dee
d)
Charlie
28.
True or False:  An array can be store different types of data (like store both doubles and ints).
a)
True
b)
False
29.

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

30.

Is String a primitive data type?

a)

Yes

b)

No

c)

Both

31.

What is the list nums if it is initially [5, 3, 1] and the following code is executed?

nums.add(6);

nums.add(0, 4);

nums.remove(1);

a)

[4, 3, 1, 6]

b)

[5, 3, 1, 6]

c)

[4, 3, 6]

d)

[4, 5, 3, 6]

32.

What index value is used to locate the last element in the nums ArrayList?

a)

nums.size()-1

b)

nums.length()-1

c)

nums.size()

d)

nums.length

33.

Which statement below is the correct way to retrieve the first element in the nums ArrayList?

a)

nums.get(0)

b)

nums[0]

c)

nums(0)

d)

nums[1]

34.
What does it mean for a list to be "dynamic"?
a)
You can easily add and remove elements
b)
It has a set size once it has been created
c)
It may contain multiple types of values
d)
You can access it from anywhere in the program
35.
How do you get the number of elements in an ArrayList called "list" in Java?
a)
list.size();
b)
list.count();
c)
list.length();
d)
list.getSize();
36.
The _________ method will return the total elements in an ArrayList.
a)
total()
b)
length()
c)
size()
d)
length
37.

How many ways a thread can be created in Java multithreading?

a)

1

b)

2

c)

5

d)

10

38.

Which method is used to make main thread to wait for all child threads

a)

Join ()

b)

Sleep ()

c)

Wait ()

d)

Stop ()

39.

Which will contain the body of the thread in Java?

a)

Start()

b)

Run()

c)

Main()

d)

Execute()

40.

The life cycle of a thread in java is controlled by

a)

JRE

b)

JDK

c)

JVM

d)

None

41.

Which method is used to get current running thread object?

a)

runningThread()

b)

currentThread()

c)

runnableThread()

d)

None

42.

Synchronized static methods acquire lock on

a)

Class

b)

Object

c)

Interface

d)

None

43.

Thread priority in Java is?

a)

Integer

b)

Float

c)

Double

d)

Long

44.

In JAVA multi threading, a thread can be created by_______

a)

Extending class

b)

Implementing Runnable Interface

c)

both

d)

none

45.

Which statements is/are correct

a)

On calling Thread start ( ) method a new thread is created

b)

Thread start( ) method call run( ) method internally

c)

Thread run( ) method can also be called directly to create thread

d)

both a & b

46.

Q) What is maximum thread priority in Java

a)

10

b)

12

c)

5

d)

8

47.

Q) Execution of a java thread begins on which method call?

a)

Start ()

b)

Run ()

c)

Execute ()

d)

Launch ()

48.

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

49.

What is the parent class of All Exceptions in JAVA

a)

Throw

b)

Exception

c)

Error

d)

Bug

50.

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

a)

try

b)

catch

c)

finally

d)

throw

51.

try block may or may not contains catch blocks

a)

True

b)

False

52.

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

53.

How to create our own exception

a)

using 'throw' keyword

b)

using 'throws' keyword

c)

using 'finally' keyword

d)

using 'throwable' keyword

54.

Exception classes belongs to following package

a)

import java.io.*

b)

import java.lang.*

c)

import java.util.*

d)

import java.lang.Exception.*

55.

Composition is a

a)

uses-a relationship

b)

has-a relationship

c)

is-a relationship

d)

none of the above

56.

What is not a Java primitive data type?

a)

float

b)

byte

c)

Boolean

d)

char

57.

Select the access level/s of a private modifier.

a)

Class

b)

Package

c)

Subclass

d)

World

58.

It keeps the data and the code safe from external interference.

a)

Polymorphism

b)

ArrayList

c)

Autoboxing

d)

Encapsulation

59.

Which data type is not supported by ArrayList?

a)

Integer

b)

String

c)

double

d)

Boolean

60.

What is an instance of a class?

a)

Class

b)

Object

c)

Reference

d)

Primitive

61.

What is the default value of a primitive int data type?

a)

-1

b)

null

c)

0

d)

garbage data

62.

Consider the given code. What would be the display on the screen?

a)

Class A

b)

Class B

c)

Class C

d)

Compile error

63.

A ___________ is a pre-defined set of steps that complete a specific task, optionally based on parameter values, and optionally returning some result.

a)

array

b)

function

c)

method

d)

module

e)

class

64.

Predict the output of the following program.


class A{

int a=40;//non static

public static void main(String args[]){

System.out.println(a);

}

}

a)

Compilation Error

b)

40

c)

0

d)

None of the above

65.

What is subclass in java?

a)

A subclass is a class that extends another class

b)

A subclass is a class declared inside a class

c)

Both above.

d)

None of the above.

66.

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

a)

super

b)

this

c)

extent

d)

extends

67.

A package is a collection of

a)

classes

b)

interfaces

c)

editing tools

d)

classes and interfaces

68.

Attributes of an object are also known as

a)

methods

b)

properties

c)

classes

d)

functions

69.

Polymorphism related to :

a)

PPO

b)

Class

c)

OPP

d)

OOP

70.

Which from the following is a feature that allows us to perform a single action in different ways.

a)

Abstraction

b)

Polymorphism

c)

Encapsulation

d)

Inheritance

71.

The process by which objects of one class acquire the properties of objects of another class is known as

a)

Polymorphism

b)

Inheritance

c)

Data Hiding

d)

Association

72.

Hiding complexity can also be termed as

a)

Inheritance

b)

Overloading

c)

Data hiding

d)

Abstraction

73.
Which of the following concepts of OOPS means exposing only necessary information to client?
a)
Encapsulation
b)
Abstraction
c)
Data hiding
d)
Data binding
74.
How many objects can be made from a class? 
a)
None, you make classes from objects
b)
one
c)
As many as you want
d)
All of the above
75.
What is the difference between a class and an object?
a)
A class is a blueprint to make an object
b)
An object is a blueprint to make a class
c)
A blueprint is an object to make a class
d)
Blueprint class is an object make a
76.

Which one is NOT the basic element of OOP?

a)

Class

b)

Abstraction

c)

BlueJ

d)

Polymorphism

77.
An object is an instance of a:
a)
parameter
b)
method
c)
class
d)
application
78.
These have identitystate, and behavior.
a)
class
b)
object
c)
method
d)
void
79.

Which of the following is the complete syntax of creating a class?

a)

public class Main { }

b)

public class Main() { }

c)

public class Main

d)

public class Main()

80.

Which of the following creates an object of Main class?

a)

Main obj = new Main;

b)

Main obj = new Main();

c)

Main obj = new Mian();

d)

Main obj == new Main();

81.

Another term for variable within a class

(a)  

82.

Methods are declared within a class.

a)

True

b)

False

83.

static void myMethod(){ }

What is the name of the method?

a)

static void myMethod

b)

void myMethod

c)

static myMethod

d)

myMethod

84.
Inheritance is used when the relationship between two classes is a(n) _______ relationship.
a)
"HAS-A"
b)
"PART-OF-A"
c)
"IS-A"
d)
inverse
85.
Which of these cannot be passed down through inheritance?
a)
Public variables
b)
Private variables
c)
Methods
d)
Data
86.

Which of the following statements is invalid?

a)

Tutor jimmy = new CSTutor();

b)

CSTutor sally = new JavaTutor();

c)

Tutor suzie = new JavaTutor();

d)

Tutor johnny = new Tutor();

87.

Identify the type of error that exists in this method program.

a)

Logic error

b)

runtime error

c)

syntax error

d)

Value error

88.

Class

a)

def class Test(){}

b)

public class Circle{}

c)

public class Circle(){}

d)

public class circle{}

89.

Extends

a)

Adds libraries to your project

b)

Extends the life of your variable when the program closes

c)

Inheritance to a parent object

d)

Polymorphism

90.

The following Syntax is used for?


class Subclass-name extends Superclass-name

{

//methods and fields

}

a)

Polymorphism

b)

Encapsulation

c)

Inheritance

d)

None of the above

91.

A class that is inherited is called a ______ .

a)

superclass

b)

Subclass

c)

subsetclass

d)

Relativeclass

92.
What does polymorphism mean?
a)
Changing shapes
b)
Having many forms
c)
Being unchangeable
d)
Easy
93.
Which of these cannot be passed down through inheritance?
a)
Public variables
b)
Private variables
c)
Methods
d)
Data
94.
In Java, each child class can have only one parent.
a)
True
b)
False
95.

which are the features of Java?

a)

main

b)

Inheritance

c)

Polymorphism

d)

Data Hiding

96.

which one of the following is a legal decelration of a two- dimensional array of integers

a)

int[] a[] = new int[5][];

b)

int[5][5] a = new int[][];

c)

int a = new int[5,5];

d)

int[][] a = new int[][5];

97.

which one this keywords are used to create a class in java

a)

class

b)

struct

c)

int

d)

none of the avove

98.

Describe method.

a)

A component of a program in a big program.

b)

A program to perform a specific task.

c)

A component of a program written to perform a specific task.

d)

A variable that use to read an input.

99.

This is a general structure a method.

a)

<Returnvalue type> <Method Name> (argument / s)

b)

<Modifier> < type> <Method Name> (parameter / s)

c)

public static void main (String[ ] args)

d)

<Method Name> (parameter)

100.

The different between static and non static method is ....

a)

for non static method : user need to create object in a class to call a method.

b)

A method is to perform only specific task.

c)

There is no significant differences between static and non - static method.

d)

Both are bounded with a class.

101.

Data type for non return method is

a)

int

b)

double

c)

void

d)

public static

102.

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

a)

i += 1

b)

i++

c)

i -= 1

d)

i--

103.

Which of the following is FALSE about arrays on Java

a)

A java array is always an object

b)

Length of array can be changed after creation of array

c)

Arrays in Java are always allocated on heap

104.

What is the length of the following array: byte[] data = { 12, 34, 9, 0, -62, 88 };

a)

1

b)

5

c)

6

d)

12

105.

class Demo1

{

public static void main(String args[])

{

int i[] = new int[10];

System.out.println(i[10]);

}

}

a)

0

b)

Garbage Value

c)

Out-of-bounds exception

d)

Error

106.
_________________ is a collection of elements used to store the same type of data.
a)
Array
b)
Switch
c)
Case
d)
Loop
107.

Which method would you use to check if two Strings are exactly the same?

a)

equals()

b)

equalsIgnoreCase()

c)

toUpperCase()

d)

toLowerCase()

108.

Which method was used to convert this String: "IT learners are clever" to "IT LEARNERS ARE CLEVER" ?

a)

toUpperCase()

b)

toLowerCase()

c)

equalsIgnoreCase()

d)

compareTo()

109.

Which method was used to convert this String: "Life is TOO SHORT to be BORED" to: "life is too short to be bored" ?

a)

toLowerCase()

b)

toUpperCase()

c)

equals()

d)

equalsIgnoreCase()