Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Java Fundamentals

Total questions: 89

Worksheet time: 43mins

Name
Class
Date
1.

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

2.

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

3.

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

4.

char is 2 byte in storage?

a)

True

b)

False

5.

Name the data type: '3'

a)

int

b)

char

c)

String

d)

None of the above

6.

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

a)

boolean

b)

String

c)

double

d)

int

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

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

9.

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

10.

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

a)

nextInt( )

b)

hasNext( )

c)

next( )

d)

nextFloat( )

11.

Predict the value of k,

int k =10;

k=k+k++;

a)

11

b)

20

c)

21

d)

22

12.

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

13.

Java was developed by

a)

James gosling

b)

John gosling

c)

James frank

d)

John frank

14.

JDK stands for (a)  

15.

JVM stands for (a)  

16.

List out types of inheritance.

a)

Single

b)

Mulitple

c)

Multi level

d)

Hierarchy

17.

List out oops concept.

4 lines
18.

Int data types represents _______ bits.

a)

8

b)

16

c)

32

d)

64

19.

There are (a)   types of data types.

20.

(a)   is a piece of memory that can contain a data value.

21.

How many types of array?

a)

1

b)

2

c)

3

d)

4

22.

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

a)

JRE

b)

JIT

c)

JDK

d)

JVM

23.

Which one of the following is not a java feature

a)

Object-oriented

b)

Use of pointers

c)

Portable

d)

Dynamic and Extensible

24.

Which of these cannot be used for a variable name in java ?

a)

Identifier & keyword

b)

Identifier

c)

Keyword

d)

None of the mentioned

25.

Which of the following is not an OOPS concept in java ?

a)

Polymorphism

b)

Inheritance

c)

Compilation

d)

Encapsulation

26.

What is the numerical range of a char data tupe in java ?

a)

0 to 256

b)

-128 to 127

c)

0 to 65535

d)

0 to 32767

27.

When does method overloading is determined?

a)

At run time

b)

At compile time

c)

At coding time

d)

At execution time

28.

When overloading does not occur ?

a)

More than one method with same name but different method signature and different number or type of parameters

b)

More than one method with same name,same signature but different number of signature

c)

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

d)

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

29.

When overloading does not occur ?

a)

More than one method with same name but different method signature and different number or type of parameters

b)

More than one method with same name,same signature but different number of signature

c)

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

d)

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

30.

Which of these data types is used to store command line arguments?

a)

a) Array

b)

b) Stack

c)

c) String

d)

d) Integer

31.

The given code will give following result

a)

"Hello"

b)

Hello

c)

Compile-time error

d)

Run-time error

32.

What will be the output of the given code?

a)

5 4

b)

4 5

c)

4 4

d)

5 5

33.

What will be the result of given programme?

a)

Hello World!

b)

Infinite loop

c)

Compile-time error

d)

Run-time error

34.

In given code of Java, String args[] is used for ......

a)

Passing arguments at compile time

b)

Passing arguments at run time

c)

Counting number of words

d)

None of the given

35.

____ keyword is used to make a class

a)

new

b)

Object

c)

Class

d)

class

36.

Which of the following is a valid syntax for creating an object of a Box class?

a)

Box obj = new Box();    

b)

Box obj = new Box;

c)

obj = new Box();

d)

new Box obj;

37.

Output of following Java Program?

a)

Derived::show() called

b)

Base::show() called

c)

Run time Error

d)

Compilation Error

38.

Output of following Java Program?

a)

10

b)

20

c)

Compilation Error

d)

Run Time Error

39.

Output of following Java Program?

a)

12

b)

321

c)

123

d)

23

40.

What will be the output of following program?

a)

Base::show() called

b)

Derived::show() called

c)

Compiler Error

d)

Runtime Error

41.

Output of following Java program?

a)

Base

Derived

Derived

b)

Base

Base

Derived

c)

Base

Derived

Base

d)

Compiler Error

42.

Predict the output of following Java Program

a)

Compiler Error

b)

Grandparent's Print()

Parent's Print()

Child's Print()

c)

Child's Print()

Parent's Print()

Grandparent's Print()

d)

Runtime Error

43.

byte is 1 byte size in storage?

a)

True

b)

False

44.

Long is 4 byte size in storage?

a)

True

b)

False

45.

char is 2 byte in storage?

a)

True

b)

False

46.

(=) sign means

a)

equals and it is used for math problems in Java

b)

assignment operator. It used to assign a value

47.

Which one is used for remainder in Java?

a)

/

b)

%

c)

+

d)

*

48.

int x = 3; in this case, which of the following statement is true?

a)

x = x+1;

b)

x++;

c)

x += 1;

d)

All of above

49.

Which of the following is NOT safe and can result in a loss of data?

a)

Narrowing primitive

b)

Widening primitive

50.

This data type returns true or false

a)

String

b)

boolean

c)

char

d)

int

51.

Name the data type: 1.0

a)

double

b)

int

c)

char

d)

boolean

52.

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

a)

boolean

b)

char

c)

int

d)

double

53.

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

54.

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

55.

Name the data type: "true"

a)

boolean

b)

char

c)

String

d)

double

56.

Name the data type: '3'

a)

int

b)

char

c)

String

d)

None of the above

57.

Name the data type: false

a)

String

b)

boolean

c)

int

d)

None of the above

58.

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

a)

boolean

b)

String

c)

double

d)

int

59.
Variables and constants in programs need to be assigned a data type.
a)
True
b)
False
60.
Expressions cannot contain variables of different data types.
a)
False
b)
True
61.
Integers cannot store negative numbers.
a)
False
b)
True
62.
If you store a smaller number in an integer, (say 10 instead of 1234,) it will take up less memory.
a)
False
b)
True
63.
What data type would be best used to record an email address?
a)
String
b)
Integer
c)
Real
d)
Character
64.
What data type would be the answer to the expression x < 5?
a)
Boolean
b)
Character
c)
Real
d)
String
65.
+
a)
Divison
b)
Multiplication
c)
Addition
d)
Subtraction
66.
Conditional Statement
a)
Statements that only run when certain conditions are true.
b)
A way to give information to a computer.
c)
Executes a series of statements a certain number of times.
d)
The information computer give to users, devices, or other computers.
67.
Arthimetic Operator
a)
/, *, -, +
b)
"<, >, ==, !=, <=, >="
c)
<
d)
>
68.
Comparison Operators
a)
"<"
b)
!=
c)
"<, >, ==, !=, <=, >="
d)
/, *, -, +
69.
IF/ELSE statement
a)
Any combination of characters (letters, numbers and symbols)
b)
A decision between two or more things.
c)
The work done (possibly by a computer) to turn an input into an output.
d)
Executes a series of statements a certain number of times.
70.

Java programs are

a)

Faster than others

b)

Platform independent

c)

Not reusable

d)

Not sacable

71.

Java has its origin in

a)

COBOL

b)

PERRL

c)

Oak programming language

d)

C language

72.

Which one of the following is true for java

a)

Java is object oriented and interpreted

b)

Java is efficient and faster than C

c)

Java is the choice of everyone

d)

Java is not robust

73.

The command javac is used to

a)

Execute a Java program

b)

Compile a Java program

c)

Debug a Java program

d)

Interpret a Java program

74.

……………. are not machine instructions and therefore, Java interpreter generates machine code that can be directly executed by the machine that is running the Java program.

a)

Compiled instruction

b)

Compiled code

c)

Byte code

d)

Java mid code

75.

Which of the following is not the Java primitive type

a)

Byte

b)

Float

c)

Character

d)

Long double

76.

Which of the following is not mandatory in a variable declaration?

a)

a semicolon

b)

an identifier

c)

an assignment

d)

a data type

77.

In Java variables, if first increment of the variable takes place and then the assignment occurs. This operation is also called…………………………

a)

pre-increment

b)

post-increment

c)

incrementation

d)

pre incrementation

78.

The information written in java after // is ignored by the

a)

Programmer

b)

Interpreter

c)

Compiler

d)

All of the above

79.

When the operators are having the same priority, they are evaluated from …………….. …………. in the order they appear in the expression.

a)

right to left

b)

left to right

c)

Any of the order

d)

Depends on the compilor

80.

When a java program is compiled, it creates a

a)

an obj file

b)

an exe file

c)

a .class file

d)

a . sh file

81.

The JDK is a superset of the JRE, and contains everything that is in the JRE, plus tools such

as the compilers and debuggers necessary for developing applets and applications.

a)

True

b)

False

82.

Bootstrap class loader is responsible for

a)

Loading the classes,

b)

Programmer defined classes

c)

Java's API classes

d)

All the above

83.
a)

128

b)

0

c)

Compilation fails with an error at line 3

d)

Compilation fails with an error at line 4

84.
a)

10,17,garbage value

b)

10,15,58

c)

Compiler Error

d)

Runtime Error

85.
a)

10

b)

9A

c)

Error occured in line 3

d)

None of the above

86.
a)

17

b)

16

c)

15

d)

Error in line no. 5

87.

What is the output for the given code segment?

a)

128

b)

0

c)

12

d)

4

88.
a)

i : 1

b)

i : 1

i : 2

c)

i : 1

i : 1

d)

i:1

i:2

89.
a)

1,2,3,4,5

b)

1,2,4,5

c)

1,2,4,5,6

d)

All are valid