wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

PROGRAMMING CAMP

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

Which of the following is a CONDITIONAL

a)

jump 5 times

b)

if you see an arrow then jump 5 times else sit down

c)

if you see an arrow

2.
Which for loop is correct?
a)
for (1; x < 5; i--)
b)
for(x; 5; ++1)
c)
for(int i = 0; i < 5; i++)
d)
for(int i = 0, i < 5, i++)
3.

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

4.

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

5.

Which of the followings is Java code that starts from the main() method as a mandatory part of every program

a)

public void static main(String args [])

b)

public void main static (args[] String)

c)

public static void main (String args[])

d)

public static void main [String [] Args]

6.

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

7.

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

8.

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

a)

Char

b)

String

c)

boolean

d)

Float

9.

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

a)

True

b)

False

10.

Identifiers can start with a number. True or False?

a)

True

b)

False

11.

The following Syntax is used for?


class Subclass-name extends Superclass-name

{

//methods and fields

}

a)

Polymorphism

b)

Encapsulation

c)

Inheritance

d)

None of the above

12.

Which of the following commands will run the compiled Java program named DoItNow?

a)

run DoItNow

b)

java DoItNow.java

c)

java DoItNow

d)

go DoItNow

13.

Assume you are at the operating system command line and want to use the following command to compile a program:

javac MyClass.java

Before entering the command you must

a)

close all open windows on your computer system

b)

make sure you are in the same directory or folder where the MyClass.java file is located

c)

execute the java.sun.com program

d)

save the program with the .comp extension

14.

A cross between human language and a programming language is called

a)

a compiler

b)

pseudocode

c)

the Java Virtual Machine

d)

the Java language

15.
Which of the following pairs of symbols are the correct ones used to create Java code comments
a)
{ }
//
b)
//
/* */
c)
/* */
'
16.
How can you save a file in BlueJ?
a)
Call File - Save from the menu bar
b)
Hit the compile button
c)
use CTRL-S for a save shortcut
17.

What is the output


class Output

{

public static void main(String args[])

{

boolean a = true;

boolean b = false;

boolean c = a ^ b;

System.out.println(!c);

}

}

a)

true

b)

1

c)

false

d)

0

18.

What is the output


class dynamic_initialization

{

public static void main(String args[])

{

double a, b;

a = 3.0;

b = 4.0;

double c = Math.sqrt(a * a + b * b);

System.out.println(c);

}

}

a)

25.0

b)

5.0

c)

Error

d)

7.0

19.

What is the output


class bitwise_operator

{

public static void main(String args[])

{

int a = 3;

int b = 6;

int c = a | b;

int d = a & b;

System.out.println(c + " " + d);

}

}

a)

7 7

b)

7 2

c)

5 2

d)

7 5

20.

What is the output


class OperatorExample{ public static void main(String args[]){ System.out.println(10*10/5+3-1*4/2); }}

a)

21

b)

44

c)

35

d)

103