Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

java Quiz

Total questions: 24

Worksheet time: 35mins

Name
Class
Date
1.

The keyword "method" is another name for

a)

an object

b)

a class

c)

a function

d)

a variable

2.

Which of the following is NOT a numeric data type

a)

int

b)

double

c)

float

d)

decimal

3.

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

4.

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

a)

int count;

b)

String name;

c)

float gpa;

d)

char firstInitial;

5.

Where does a java program start executing instructions from:

a)

class

b)

source file

c)

main method

d)

object

6.
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();
7.
A variable that holds a whole number
a)
String
b)
boolean
c)
int
d)
float
8.
What is at the end of a line of code?
a)

#Number sign

b)

; Semicolin

c)

) Close parenthesies

d)

>Less than

9.
These controls the behavior of a program.
a)
class
b)
object
c)
method
d)
void
10.

int len = "jump it!".length();


What is the value of len?

a)

8

b)

7

c)

9

d)

6

e)

This code does not compile.

11.

Which keyword is used to create an object in Java?

a)

create

b)

object

c)

new

d)

make

12.

What does the following print out?

int a = 10;

a += 5;

a *= 2;

a++;

System.out.println(a);

a)

10

b)

21

c)

31

d)

20

e)

30

13.
Choose a Single Line Comment in Java Language below?
a)
//Some comments
b)
Some comments//
c)
/*Some comments*/
d)
*/Some comments/*
14.

Which one is the proper format for a multi-line comment in Java?

a)

//

Hello

World

//

b)

*/

Hello

World

/*

c)

/*

Hello

World

*/

d)

There's no such thing

15.

--------- is a symbol, that operates on operands and produce a result

a)

operands

b)

variables

c)

operators

d)

Ternary

16.

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();

17.

What type of language is Java?

a)

Object Oriented

b)

Scripting

c)

Assembly

d)

Pseudocode

18.

How do you properly extend a class?

a)

public class extends class

b)

private class2 extends class

c)

public class2 extends class

d)

private class2 extends class

19.

public class Box

{

int width;

int height;

int length;

public Box(int w, int h, int l){

//constructor code here}

}

class mainclass

{

public static void main(String args[])

{

Box obj1 = new Box();

Box obj2 = new Box();

obj1.height = 1;

obj1.length = 2;

obj1.width = 1;

obj2 = obj1;

System.out.println(obj2.height);

}

}

What is printed out?

a)

1

b)

2

c)

Runtime error

d)

There is no value printed out

20.

In Java null is:

a)

The initial value of an object variable.

b)

A key word

c)

A value that means not pointing to any object

d)

All of these

e)

None of these

21.

Which type of data is used to enter the value (1234.5)?

a)

Integer

b)

double

c)

char

d)

void

22.

The string method length() returns what?

a)

The size in memory of the string

b)

The number of symbols in a string

c)

How long the biggest word is

d)

A measurement of how long the program has run

23.

What will be the output of the code give below:

  class yes

{

public static void main(String[] args)

{

int Integer = 24;

char String  = 'I';

System.out.print(Integer);

System.out.print(String);

}}

a)

24I

b)

24

c)

I24

d)

24

I

24.

What do you use to compare two strings' contents?

a)

==

b)

=

c)

.equals()

d)

.isEqual()