wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Java Fundamental Test 01

Total questions: 96

Worksheet time: 2hrs 36mins

Name
Class
Date
1.

Java was developed by

a)

James gosling

b)

John gosling

c)

James frank

d)

John frank

2.

The keyword "method" is another name for

a)

an object

b)

a class

c)

a function

d)

a variable

3.

Which of the following is NOT a numeric data type

a)

int

b)

double

c)

float

d)

decimal

4.

Which of the following is incorrect?

a)

int count = 50.0;

b)

int salary = 50_000;

c)

int salary = 50_00;

d)

all of these are incorrect

5.

The numeric type int uses how many bits?

a)

31

b)

32

c)

63

d)

64

6.

Which of the following is an example of a reference variable declaration?

a)

int count;

b)

String name;

c)

float gpa;

d)

char firstInitial;

7.

Where does a java program start executing instructions from:

a)

class

b)

source file

c)

main method

d)

object

8.
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
9.
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();
10.
A variable that holds a whole number
a)
String
b)
boolean
c)
int
d)
float
11.
A variable that holds words
a)
String
b)
boolean
c)
int
d)
float
12.
A variable that holds a decimal number
a)
String
b)
boolean
c)
int
d)
float
13.
A variable that holds a character
a)
String
b)
boolean
c)
int
d)
char
14.
What is at the end of a line of code?
a)
#
b)
;
c)
)
d)
>
15.
What does a comment look like in Java?
a)
//comment
b)
\\comment
c)
==comment
d)
\comment
16.

What is the main difference between float and double data types?

a)

4.1 is an example of float.

b)

4.11 is an example of double.

c)

Float consists of 8 bytes, and double consists of 4 bytes.

d)

Float consists of 4 bytes, and double consists of 8 bytes.

17.

What kind of data type is used for numbers?

a)

Integer

b)

String

c)

Boolean

d)

Floating Point

18.

Java Tokens help the compiler. Which of the following is a type of Java Token?

a)

Identifiers

b)

Keywords

c)

Operators

d)

All of the answers.

19.

Java is a

a)

Procedure Oriented Language

b)

Structure Oriented Language

c)

Object_Oriented Language

d)

Machine Language

20.

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

a)

Object Name

b)

Variable Nam

c)

Class Name

d)

Array Name

21.

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

a)

Object file

b)

Array file

c)

Class file

d)

String file

22.

Command to compile Java program

a)

javax

b)

javay

c)

javac

d)

Java

23.

Command to run a Java program

a)

javaa

b)

java

c)

jaava

d)

jaavaa

24.

JDK stands for

a)

Java Developer Kit

b)

Java Development Kit

c)

Java Design Kit

d)

Java Debugging Kit

25.

JRE stands for

a)

Java Run Environment

b)

Java Run Execution

c)

Java Runtime Environment

d)

Java Ready Execution

26.

Java is

a)

Machine dependent language

b)

Machine independent language

27.

In Java WORA stands for

a)

Write Once Recall Anywhere

b)

Write Once Return Anywhere

c)

Write Once Read Anywhere

d)

Write Once Run Anywhere

28.

JVM stands for

a)

Java Vital Machine

b)

Java Virtual Machine

c)

Java Vendor machine

29.

Java programs ________________

a)

are only compiled

b)

are only compiled not interpreted

c)

are only interpreted

d)

are both compiled and interpreted

30.

Main() method is not mandatory for a Java program

a)

True

b)

False

31.

Which of the following personality is called as father of Java Programming language –

a)

Guido vom Russom

b)

Larry Page

c)

Bjarne Stroustrup

d)

James Gosling

32.

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

a)

JDK

b)

JRE

c)

JVM

d)

JIT

33.

The icon of Java program is taken from ___.

a)

a cup of coffee

b)

a tornado that spits fire

c)

a volcano under water

d)

a candle with a flame

34.

What output will be produced by:


System.out.print("\\* This is not\n a comment *\\"):

a)

* This is not a comment *

b)

\* This is not a comment *\

c)

* This is not

a comment *

d)

\\* This is not

a comment *\\

e)

\* This is not

a comment *\

35.

What value is stored in result if:


int result = 13 - 3 * 6 / 4 % 3;

a)

-5

b)

0

c)

13

d)

-1

e)

12

36.

Suppose that addition and subtraction had higher precedence than multiplication and division. Then the expression:


2 + 3 * 12 / 7 - 4 + 8


would evaluate to which of the following?

a)

11

b)

12

c)

5

d)

9

e)

-4

37.
What are booleans in JAVA?
a)
True or False statements
b)
A way to lean the coding to one side.
c)
A way to write numbers.
d)
They are the proper way of writing code.
38.
How do I insert a multi-line comment?
a)
/* Comment */
b)
? Comment ?
c)
Comment **
d)
-Java Comment-
39.

Name the data type: "true"

a)

boolean

b)

char

c)

String

d)

double

40.

Name the data type: 1.0

a)

double

b)

int

c)

char

d)

boolean

41.

Name the data type: '3'

a)

int

b)

char

c)

String

d)

None of the above

42.

Name the data type: false

a)

String

b)

boolean

c)

int

d)

None of the above

43.

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

a)

boolean

b)

String

c)

double

d)

int

44.

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

a)

double

b)

String

c)

int

d)

char

45.

What data type would you use for storing letter grades (without - or +) for students in a class?

a)

String

b)

char

c)

int

d)

boolean

46.

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

a)

String

b)

char

c)

boolean

d)

None of these

47.

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

a)

string name = "Jeff";

b)

name String = "Jeff";

c)

String name = Jeff;

d)

String name = "Jeff";

48.

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

49.

Which expression evaluates to false?

a)

15 % 3 < 2

b)

3 * 3 % 2 <= 0

c)

false == false

d)

false == false == false == false

50.

Which declaration will throw an error?

a)

double num = 8;

b)

int averageGrade = 89.7;

c)

boolean done = false;

d)

String done = "true";

51.

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

52.

Consider the following code segment:

Line 1: int a = 10;

Line 2: double b = 10.7;

Line 3: double c = a + b;

Line 4: int d = a + c;

Line 5: System.out.println(c + " " + d);


What will be output as a result of executing the code segment?

a)

20 20

b)

20.0 30

c)

20.7 31

d)

20.7 30.7

e)

Nothing will be printed because of a compile-time error.

53.

Consider the following code segment:


Line 1: int a = 11;

Line 2: int b = 4;

Line 3: double x = 11;

Line 4: double y = 4;

Line 5: System.out.print(a / b);

Line 6: System.out.print(", ");

Line 7: System.out.print(x / y);

Line 8: System.out.print(", ");

Line 9: System.out.print(a / y);


What is printed as a result of executing the code segment?

a)

3, 2.75, 3

b)

3, 2.75, 2.75

c)

2, 3, 2

d)

2, 2,75, 2.75

e)

Nothing will be printed because of a compile-time error.

54.

Consider the following code segment:


int var = 12;

var = var % 7;

var = var - 1;

System.out.println(var);


What is printed as a result of executing the code segment?

a)

0

b)

1

c)

2

d)

4

e)

5

55.

Consider the following code segment:


int count = 5;

double multiplier = 2.5;

int answer = (int)(count * multiplier);

answer = (answer * count) % 10;

System.out.println(answer);


What is printed as a result of executing the code segment?

a)

0

b)

2.5

c)

6

d)

12.5

e)

60

56.

Which is a valid keyword in java?

a)

interface

b)

string

c)

Float

d)

unsigned

57.

What type of literal is "null"?

a)

null Literal

b)

Character Literal

c)

String Literal

d)

It is not a Literal

58.

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

a)

nextInt( )

b)

hasNext( )

c)

next( )

d)

nextFloat( )

59.

What is the value of c after int c = 'B'+3; is executed?

a)

101

b)

69

c)

Code is incorrect

d)

B3

60.

What is the value of c after int c = 'B'+3; is executed?

a)

101

b)

69

c)

Code is incorrect

d)

B3

61.

What is the value of p after the following statement is executed?

int p=4538%100

a)

8

b)

38

c)

4538

d)

4

62.
Which identifier is not legal in java?
a)
class
b)
2legit2quit
c)
HappyDays$
d)
Whats_up_with_that
63.

Which of the following terms mean "will not return any value"?

a)

public

b)

static

c)

void

d)

main()

64.

Which component is responsible to optimize bytecode to machine code?

a)

JRE

b)

JVM

c)

JDK

d)

JIT

65.

Which statement is true about java?

a)

Sequence dependent programming language

b)

Code dependent programming language

c)

Platform independent programming language

d)

Platform dependent programming language

66.

JVM is _____

a)

code dependent

b)

code independent

c)

platform dependent

d)

platform independent

67.

What is the extension of compiled java classes?

a)

.class

b)

.js

c)

.txt

d)

.java

68.

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

a)

The applet makes the Java code secure and portable

b)

Use of exception handling

c)

Dynamic binding between objects

d)

Bytecode is executed by JVM

69.

In which memory a String is stored, when we create a string using new operator?

a)

Stack

b)

String memory

c)

Random storage space

d)

Heap memory

70.

correct execution process in Java

a)

load->edit->compile->verify->execute

b)

edit->load->compile->execute->verify

c)

edit->compile->load->verify->execute

d)

verify->edit->compile->load->execute

71.

Which of the following are Java features?

a)

Object- oriented programming

b)

Class- based programming

c)

Bytecode is platform independent

d)

All of above

72.

Which of the following are Java features?

a)

Object- oriented programming

b)

Class- based programming

c)

Bytecode is platform independent

d)

All of above

73.

What does IDE mean?

a)

Integration Development Environment

b)

Integration Device Environment

74.

Which one is correct?

a)

public static main(Strings[] args) { }

b)

public private static main(Strings[] args) { }

c)

public static void main(Strings[] args) { }

d)

public void static main(Strings[] args) { }

75.

char is 2 byte in storage?

a)

True

b)

False

76.

(=) sign means

a)

equals and it is used for math problems in Java

b)

assignment operator. It used to assign a value

77.

Which one is used for remainder in Java?

a)

/

b)

%

c)

+

d)

*

78.
Platform independent code file created from Source file is understandable by _______________.
a)
Applet
b)
Compiler
c)
JRE
d)
JVM
79.
JVM is a _____________ .
a)
Compiler
b)
Interpreter
c)
Assembler
d)
Debugger
80.

Which of the below is/are valid identifier with the main method?

a)

public

b)

private

c)

static

d)

this

81.

What is the extension of java code files?

a)

.class

b)

.txt

c)

.java

d)

.js

82.

Compilation statement in java

a)

java filename

b)

javac filename

c)

java filename.java

d)

javac filename.java

83.

Which statement is used to run the java program?

a)

javac filenemae.java

b)

java filename

c)

javac filename

d)

java filename.java

84.

java compiler converts the java file into _________ file.

a)

.jvm

b)

.class

c)

.obj

d)

.java

85.

.class file of any java program can run on any machine. Is it true or false

a)

true

b)

false

86.

public static void main(String args[]). In this statement what is args[]?

a)

name of a variable

b)

Array variable which is of string type

c)

variable

d)

string variable

87.

Which of the following is true?

a)

public static void main(String args[])

b)

public static void main(String a[])

c)

public static void main(String arg[])

d)

All the above

88.

Reason for declaring main() as static.

a)

to use static variable

b)

to use static methods inside main()

c)

Need not to create obj for accessing members of main()

d)

None of the above

89.

When command line arguments are passed to the main()?

a)

While declaring method

b)

During Compile time of the program

c)

During Runtime of the program

d)

When calling main()

90.

Which is NOT a property of Java

a)

Object-Oriented

b)

Dynamically Typed

c)

Distributed and Multi-Threaded

d)

Architechturally Neutral

91.

The program Eclipse is an example of what?

a)

Debugger

b)

Text Editor

c)

Compiler

d)

Integrated Development Environment (IDE)

92.

All Java programs must be contained inside of which programming structure?

a)

class

b)

comment

c)

function

d)

bytecode

93.

Which instruction can be used to print "Hi" to the screen?

a)

System.out.printline("Hi");

b)

System.out.println("Hi");

c)

System.out.println("Hi")

d)

System.println("Hi");

94.

What file extension do all Java source code files need to have?

a)

.class

b)

.txt

c)

.py

d)

.java

95.

________ operator is used to check the equality of two values

a)

>=

b)

=

c)

*=

d)

==

96.

JVM is a _____________

a)

Hardware

b)

Software