Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Java Programming

Total questions: 40

Worksheet time: 13mins

Name
Class
Date
1.

JDK stands for (a)  

2.

JVM stands for (a)  

3.

Which of the following is a comment in the Java language?

a)

/ comment /

b)

/* comment */

c)

/ comment */

d)

<-- comment -->

4.

Which of the following is the correct main() method signature in Java?

a)

public static void main (String [] args)

b)

public static void Main (String [] args)

c)

public static void main (string [] args)

d)

public static void main (String args)

5.

Which of the following is a valid variable declaration in Java?

a)

int 1myInteger = 0;

b)

int int = 0;

c)

Int my Integer = 0;

d)

int myInteger = 0;

6.

Which Java data type is used to store 64-bit floating-point numbers?

a)

int

b)

long

c)

float

d)

double

7.

The import statement used in Java to access the Scanner class is:

a)

import java.Scanner;

b)

import java.util.Scanner;

c)

import java.package.Scanner

d)

import.java.util.Scanner;

8.

What is pseudocode?

a)

A simple java-like programming language

b)

Statements in plain English

c)

A control structure used in Java

d)

A java class

9.

What is a class in object-oriented programming?

a)

A class is a template with data and methods

b)

A class is a package

c)

A class is the declared object in memory

d)

A class is a reference object in memory

10.

Which of the following is a reserved word in Java?

a)

export

b)

import

c)

input

d)

output

11.

Which of the following is not a Java features?

a)

Dynamic

b)

Architecture Neutral

c)

Use of pointers

d)

Object-oriented

12.

According to you, what is Java? Choose two applicable answers.

a)

A mediator between you and your computer

b)

A programming language

c)

An island

d)

A video game console

13.

Which of this command is the correct way of printing in Java?

a)

System.Out.print

b)

System.out.Print

c)

System.out.print

d)

system.out.print

14.

Which of this command has errors? Select multiple

a)

System.out.print("Hello World")

b)

System.out.print(Hello World);

c)

System.out.Print("Hello World);

d)

System.out.print("Hello World");

15.

It is an optional statement used to describe what a program or a line of program is doing.

a)

tag

b)

command

c)

code

d)

comment

16.

A data type which is typical in form and make use of digits and a decimal point

a)

integer

b)

float

c)

char

d)

boolean

17.

What data type is classified as a sequenced of characters with double quotes.

a)

Char

b)

String

c)

boolean

d)

Float

18.

True or False : Java is case sensitive, which means identifier Hello and hello would have different meaning in Java

a)

True

b)

False

19.

What is the output for the following statement:

System.out.print("1"+"1");

a)

11

b)

2

c)

Error Message

20.

Indicate the actual output of the statements below:

int thisYear = 2020;

System.out.println("The current year is "+thisYear);

a)

The current year is thisYear

b)

The current year is 2020

c)

No output; an error exists

d)

The current year is

21.

Which of the following is used as a terminator in Java programming?

a)

)

b)

;

c)

.

d)

>

22.

int x= 10;

int y = 20;

int z = x + y;

System.out.println(z);

Guess the output.

a)

1020

b)

10 20

c)

30

d)

"10 20"

23.

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

24.

what is the output of this question?

class Test1 {

static int x = 10;

public

static void main(String[] args)

{

Test1 t1 = new Test1();

Test1 t2 = new Test1();

t1.x = 20;

System.out.print(t1.x + " ");

System.out.println(t2.x);

}

}

a)

10 10

b)

20 20

c)

10 20

d)

20 10

25.

What is the output of this question?

class Test1 {

static int i = 1;

public static void main(String[] args)

{

for (int i = 1; i < 10; i++) {

i = i + 2;

System.out.print(i + " ");

}

}

}

a)

3 6 9

b)

3 6 9 …. 27

c)

Error

d)

none

26.

What is the output of this question?

class Test1 {

static int i = 1;

public static void main(String[] args)

{

int i = 1;

for (Test1.i = 1; Test1.i < 10; Test1.i++) {

i = i + 2;

System.out.print(i + " ");

}

}

}

a)

1 3 9

b)

1 2 3 … 9

c)

3 5 7 9 11 13 15 17 19

d)

None

27.

Keywords like final cannot be used as identifiers because they are the reserved keywords. True or False?

a)

True

b)

False

28.
_________________ is a collection of elements used to store the same type of data.
a)
Array
b)
Switch
c)
Case
d)
Loop
29.
What are the legal indexes for the array ar, given the following declaration:
int[] ar = {2, 4, 6, 8 }
a)
 0, 1, 2, 3
b)
 1, 2, 3, 4
c)
2, 4, 6, 8
d)
 0, 2, 4, 6
30.

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)

31.

Insertions within the code that explain the purpose of the code statements.

a)

Algorithms

b)

Requirements

c)

Comments

d)

Solutions

32.

In object-oriented terminology, the characteristics of an object are defined by its ____.

a)

attributes

b)

class

c)

instance

d)

methods

33.

______is the capability of an object to have data functionality available to the user without the user having to understand the implementation within the object.

a)

Polymorphism

b)

Aggregation

c)

Encapsulation

d)

Inheritance

34.

A console application uses a graphical user interface.

a)

True

b)

False

35.

A ______ should always start with an uppercase first letter.

a)

Object

b)

Class

c)

Variable

d)

Array

36.

Is the entry point into the application.

a)

Public

b)

Static

c)

Void

d)

main()

37.

It marks the beginning and the end of a block of code.

a)

{}

b)

()

c)

[]

d)

<>

38.

Which of the following is an INCORRECT syntax in Java Programming?

a)

int num1 = 15;

b)

int num1;

num 1 = 15;

c)

double num1 = 3.14d;

d)

num1 = 15;

39.

Identifier Names are case sensitive ("myVar" and "myvar" are different variables)

a)

Yes

b)

No

c)

Maybe Yes

d)

Maybe No

40.

It Increases the value of a variable by 1

a)

+

b)

++

c)

/+

d)

/++