wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Java Basics

Total questions: 35

Worksheet time: 18mins

Name
Class
Date
1.

Java is a

a)

Procedure Oriented Language

b)

Structure Oriented Language

c)

Object_Oriented Language

d)

Machine Language

2.

The name of the main template used in Java should be the

a)

Object Name

b)

Class Name

c)

Variable Name

d)

Array Name

3.

Java program is

a)

Interpreted

b)

Compiled

4.

Java program does not run without the following method

a)

main()

b)

system()

c)

void()

d)

user()

5.

A ___ file is created after compilation of a Java program.

a)

Class file

b)

Object file

c)

Array file

d)

String file

6.

Java is a

a)

Machine language

b)

Higher-level language

7.

The keyword "method" is another name for

a)

a variable

b)

a class

c)

a function

d)

an object

8.

Which of the following is NOT a numeric data type

a)

int

b)

float

c)

double

d)

decimal

9.

Which of the following is incorrect ?

a)

int count = 50.0;

b)

int salary = 50_00;

c)

int salary = 50_000;

d)

all of these are incorrect

10.

The numeric type FLOAT uses how many bits?

a)

31

b)

32

c)

63

d)

64

11.

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

a)

int count;

b)

float gpa;

c)

String name;

d)

char firstInitial;

12.

Where does a java program start executing instructions from:

a)

class

b)

main method

c)

source file

d)

object

13.

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

a)

public

b)

static

c)

void

d)

main()

14.

When we want to print in Java, we use the code ......

a)

system.out.print();

b)

System.Out.Printf();

c)

System.out.println();

d)

System.out.show();

15.

A variable that holds a whole number

a)

String

b)

int

c)

boolean

d)

float

16.

A variable that holds words

a)

String

b)

int

c)

boolean

d)

float

17.

A variable that holds a decimal number

a)

String

b)

int

c)

boolean

d)

float

18.

A variable that holds a character

a)

String

b)

int

c)

boolean

d)

char

19.

What is at the end of a line of code?

a)

#

b)

;

c)

)

d)

>

20.

These controls the behavior of a program.

a)

class

b)

object

c)

method

d)

void

21.

What does a comment look like in Java?

a)

//comment

b)

\\comment

c)

\comment

d)

==comment

22.

A variable that holds true or false

a)

String

b)

int

c)

boolean

d)

float

23.

How would you declare a variable storing the sales tax rate (like 7%)?

a)

int taxRate = 5.1;

b)

String taxRate = "5.1";

c)

double taxRate = 5.1;

d)

I do hereby declare thee Sir Tax Rate

24.

Which declaration will throw an error?

a)

double num = 8;

b)

int averageGrade = 89.7;

c)

boolean done = false;

d)

String done = "true";

e)

Mrs Coile throwing a baseball

25.

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 hurtme. No more.

26.

int sum1 = 100 + 50;

int sum2 = sum1 + 250;

int sum3 =sum2 + sum2;

System.out.println(sum3);

What will be the

a)

950

b)

800

c)

sum2sum2

d)

sum1250

27.

Which of the following is assignment operator?

a)

==

b)

++

c)

+

d)

=

28.

int x = 10;

x = x + 5;

System.out.println(x);

What will be the output?

a)

5

b)

15

c)

x5

d)

55

29.

x /= 3

Which of the below statements matches with above statement?

a)

x = 3 / x

b)

x / 3

c)

x = x / 3

d)

x /x = 3

30.

What is the output of below code?

int x = 4.4;

int y = 5.5;

System.out.println(x == y);

a)

4.4

b)

5.5

c)

9.9

d)

Error

31.

Which of the following terms means the main method is accessible everywhere within the class?

a)

public

b)

static

c)

void

d)

main

32.

You are writing a Java program that needs to manipulate very large integer values that may exceed 12 digits. The values can be positive or negative. Which data type should you use to store a variable like this?

a)

int

b)

float

c)

double

d)

boolean

33.

You are developing an algorithm for a retail Web site. You need to calculate discounts on certain items based on the quantity purchased. You develop the following decision table to calculate the discount. If a customer buys 50 units of an item, what discount will be applicable to the purchase?

a)

5 percent

b)

10 percent

c)

15 percent

d)

20 percent

34.

You are developing an algorithm before you write the C# program. You need to perform some calculations on a number. You develop the following flowchart for the calculation:


If the input value of n is 5, what is the output value of the variable fact according to this flowchart?

a)

720

b)

120

c)

24

d)

6

35.

You need to gain a better understanding of the solution before writing the program. You decide to develop an algorithm that lists all necessary steps to perform an operation in the correct order. Any technique that you use should minimize complexity and ambiguity. Which of the following techniques should you use?

a)

flowchart

b)

decision table

c)

Java program

d)

A paragraph in English