wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

MIDTERM -Application Dev

Total questions: 89

Worksheet time: 45mins

Name
Class
Date
1.

which one of these events will cause the thread to die?

a)

on calling the sleep() method.

b)

when the execution of the run() method ends

c)

when the execution of the start() method ends

d)

on calling the wait() method

2.

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

a)

class

b)

struct

c)

int

d)

none of the avove

3.

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

a)

OutputStream

b)

Reader

c)

InputStream

d)

Writer

4.

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];

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 of the following is wrapper class in java

a)

Float

b)

Integer

c)

Double

d)

all of above

8.

++ increases the value of a variable by 1

a)

assignment operator

b)

decrement operator

c)

increment operator

d)

sentinel

9.

What would the new value of A be?

A=1;

a++;

a)

1

b)

2

c)

3

d)

4

10.

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

11.

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

a)

i += 1

b)

i++

c)

i -= 1

d)

i--

12.

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

a)

bitwise operator

b)

subtraction operator

c)

equality operator

d)

arithmetic operator

13.

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

14.

arithmetic operators return a value. True or false?

a)

true

b)

false

15.

conditional operators does not return a value

a)

true

b)

false

16.

which data types work on bitwise operators?

a)

byte

b)

double

c)

char

d)

int

17.

which type of operator it is? i + =5

a)

addition assignment operator

b)

conditional operator

c)

arithmetic operator

d)

equality operator

18.

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

19.

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

20.

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

21.

Please write correct output in following space-

a)

10

b)

20

c)

No Output

d)

Error

22.
A variable that holds a whole number
a)
String
b)
boolean
c)
int
d)
float
23.

A variable that holds words

a)

String

b)

boolean

c)

int

d)

float

e)

A dictionary

24.

A variable that holds true or false

a)

String

b)

boolean

c)

int

d)

float

e)

Alex Trebek

25.

Name the data type: 1.0

a)

double

b)

int

c)

char

d)

boolean

26.

Name the data type: "true"

a)

boolean

b)

char

c)

String

d)

double

27.

Name the data type: false

a)

String

b)

boolean

c)

int

d)

None of the above

28.

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

a)

boolean

b)

String

c)

double

d)

int

29.

What data type would you use for storing the average test score in a class?

a)

double

b)

String

c)

int

d)

char

30.

What data type would you use to store names of students?

a)

String

b)

char

c)

boolean

d)

None of these

e)

blonde

31.

How would you declare a variable storing the tax rate?

a)

int taxRate = 5.1;

b)

taxRate = "5.1";

c)

double taxRate = 5.1;

d)

double taxRate = "5.1";

e)

I do hereby declare thee Sir Tax Rate

32.

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

33.

How would you declare a variable that tells you that someone passed a class?

a)

boolean passed = 'true';

b)

boolean passed = true;

c)

passed = true;

d)

String passed = "true";

e)

Trick question - no one passes this class

34.

Which declaration will throw an error?

a)

double num = 8;

b)

int averageGrade = 89.7;

c)

boolean done = false;

d)

String done = "true";

35.

What prints out "I love Java" successfully?

a)

System.out.println(I love Java);

b)

Systemoutprintln("I love Java);

c)

System.out.println("I love" + " Java");

d)

System.out.println("I love Java")

e)

What is love? Baby dont hurt me. Dont hurt me. No more.

36.

A computer walks into a bar...

a)

Ouch.

b)

Sorry, we don't server here.

c)

ERROR 404: Does not compute

d)

Great, computers are self-aware now.

37.

Java was originally named

a)

Oak

b)

C++-++

c)

Advanced C++

d)

Coffee

38.

Java is a (a)   language

39.

Choose the correct order of the Java program execution.

A. Class Loader

B. Interpretation

C. Compilation

D. Byte Code Verification

E. Java Source Code

F. Execution

a)

E-C-A-D-B-F

b)

A-C-B-D-F-E

c)

E-C-B-A-D-F

d)

E-B-C-A-D-F

40.

Which of the following is used to load a .class file?

a)

Class Loader

b)

JIT compiler

c)

Byte Code verifier

d)

Interpreter

41.

JVM stands for (a)  

42.

How many class files will be created for the following code?

class A { .... }

class B { .... }

public class C

{

public static void main(String args[])

{

...... } }

Note: Assume that A,B and C are in same file TestClass.java

a)

1

b)

2

c)

3

d)

0

43.

Java is a pure object oriented programming language.

a)

Yes

b)

No

44.

The keyword "method" is an another name for?

a)

function

b)

variable

c)

class

d)

object

45.

Where does a java program starts its execution?

a)

class

b)

main

c)

method

d)

object

46.

What will be the Output o the following code?

class Sample{

public static void main(String args[])

{

int len = args.length;

System.out.println(len);

}

}

a)

Compilation Error

b)

Runtime Error

c)

The program compiles and executes successfully but prints nothing

d)

The program compiles and executes successfully and prints 0

47.

If we want to print "I am new to Java" in java, we have to write (a)  

48.

Which of the following option leads to the portability and security of Java?

a)

Bytecode is executed by JVM

b)

The applet makes the Java code secure and portable

c)

Use of exception handling

d)

Dynamic binding between objects

49.

Which of the following is not a Java features?

a)

Dynamic

b)

Architecture Neutral

c)

Use of pointers

d)

Object-oriented

50.

_____ is used to find and fix bugs in the Java programs.

a)

JVM

b)

JRE

c)

JDK

d)

JDB

51.

Which of the following is a valid declaration of a char?

a)

char ch = '\utea';

b)

char ca = 'tea';

c)

char cr = \u0223;

d)

char cc = '\itea';

52.

What does the expression float a = 35 / 0 return?

a)

0

b)

Not a number

c)

Infinity

d)

Run time exception

53.

What does the expression float a = 35 / 0 return?

a)

0

b)

Not a number

c)

Infinity

d)

Run time exception

54.

What does the expression float a = 35 / 0 return?

a)

0

b)

Not a number

c)

Infinity

d)

Run time exception

55.

Evaluate the following Java expression, if x=3, y=5, and z=10:

++z + y - y + z + x++

a)

24

b)

23

c)

20

d)

25

56.

Which of the following for loop declaration is not valid?

a)

for ( int i = 99; i >= 0; i / 9 )

b)

for ( int i = 7; i <= 77; i += 7 )

c)

for ( int i = 20; i >= 2; - -i )

d)

for ( int i = 2; i <= 20; i = 2* i )

57.

Which of the following is not OOPS concept in Java?

a)

Inheritance

b)

Encapsulation

c)

Polymorphism

d)

Compilation

58.

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

59.

When does method overloading is determined?

a)

At run time

b)

At compile time

c)

At coding time

d)

At execution time

60.

Which concept of Java is a way of converting real world objects in terms of class?

a)

Polymorphism

b)

Encapsulation

c)

Abstraction

d)

Inheritance

61.

Which concept of Java is achieved by combining methods and attribute into a class?

a)

Encapsulation

b)

Inheritance

c)

Polymorphism

d)

Abstraction

62.

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

a)

JVM

b)

JDK

c)

JIT

d)

JRE

63.

Which of the below is invalid identifier with the main method?

a)

public

b)

static

c)

final

d)

private

64.

What is use of interpreter?

a)

They convert bytecode to machine language code

b)

They read high level code and execute them

c)

They are intermediated between JIT and JVM

d)

It is a synonym for JIT

65.

What is the extension of compiled java classes?

a)

.java

b)

.class

c)

.txt

d)

.js

66.

Which of these keywords is used to make a class?

a)

class

b)

struct

c)

int

d)

none of the mentioned

67.

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

68.

Which of the following statements is correct?

a)

Public method is accessible to all other classes in the hierarchy

b)

Public method is accessible only to subclasses of its parent class

c)

Public method can only be called by object of its class

d)

Public method can be accessed by calling object of the public class

69.

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

a)

super

b)

this

c)

extend

d)

extends

70.

Which of the following statements is correct?

a)

Public method is accessible to all other classes in the hierarchy

b)

Public method is accessible only to subclasses of its parent class

c)

Public method can only be called by object of its class

d)

Public method can be accessed by calling object of the public class

71.

Java was originally named:

a)

Coffee

b)

Oak

c)

New C++

d)

Duke

72.

Is Android based on Java?

a)

True

b)

False

73.

Who invented Java?

a)

James Gosling

b)

Sergey Brin

c)

Steve Jobs

d)

Bill Gates

e)

Tim Berners-Lee

74.

Which company owns Java?

a)

Oracle

b)

Microsoft

c)

Google

d)

Apple

e)

Intel

75.

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

a)

.java.

b)

.javac.

c)

.src.

d)

.class.

76.

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};

77.

Where does a java program start executing instructions from:

a)

class

b)

source file

c)

main method

d)

object

78.

Which of the following can be operands of arithmetic operators?

a)

Numeric

b)

Boolean

c)

Both Numeric & Characters

d)

Characters

79.

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;

int d;

c = ++b;

d = a++;

c++;

b++;

++a;

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

}

a)

3 2 4

b)

3 2 3

c)

2 3 4

d)

2 4 4

e)

3 4 4

80.

Which of these can be returned by the operator &?

a)

Integer

b)

Boolean

c)

Integer or Boolean

d)

Character

81.

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)

4

c)

6

d)

14

82.

Which of these can not be used for a variable name in Java?

a)

identifier

b)

identifier & keyword

c)

keyword

d)

none of the mentioned

83.

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 9

d)

27 8

84.

Which of the following is not an operator in Java?

a)

instanceof

b)

sizeof

c)

>>>=

d)

new

85.

What will be the output of the following Java program?

class jump_statments {

public static void main(String args[]) {

int x = 2;

int y = 0;

for ( ; y < 10; ++y) {

if (y % x == 0)

continue;

else if (y == 8)

break;

else

System.out.print(y + " "); }

}

}

a)

1 3 5 7

b)

2 4 6 8

c)

1 3 5 7 9

d)

1 2 3 4 5 6 7 8 9

86.

Which of the following loops will execute the body of loop even when condition controlling the loop is initially false?

a)

while

b)

do-while

c)

for

d)

none of the mentioned

87.

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)

5

b)

6

c)

true

d)

false

88.

Which of these is not a bitwise operator?

a)

&

b)

&=

c)

|=

d)

<=

89.

What is the output of relational operators?

a)

Integer

b)

Boolean

c)

Characters

d)

Double