Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Class 8 Program coding Java

Total questions: 13

Worksheet time: 7mins

Name
Class
Date
1.
Every statement in Java language should end with a?
a)
Dot or Period
b)
Comma
c)
Semicolon
d)
Colon
2.

All functions and variables in Java language are kept inside a?

a)
File
b)
Class or Interface
c)
Static Method
d)
main
3.
What is the extension of java source file ?
a)
.obj
b)
.class
c)
.java
d)
.exe
4.
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();
5.

Who invented Java?

a)

James Gosling

b)

Sergey Brin

c)

Steve Jobs

d)

Bill Gates

e)

Tim Berners-Lee

6.

public void main()

{

double temp = 56.0;

if (temp <=54.0 && temp>40)

System.out.println(“It is too hot”);

else if ( temp<40 || temp>30)

System.out.println(“It is hot but not too much”);

else

System.out.println(“It is pleasant”);

}


What will be the output?

a)

It is too hot

b)

It is pleasant

c)

It is hot but not too much

d)

runtime error

7.

PREDICT THE OUTPUT:

int x = 20;

int y = 18;

if(x>y)

System.out.println("x is greater than y");

else

{

System.out.println("Error");

System.out.println("Incorrect code");

}

a)

Error

b)

Incorrect code

c)

x is greater than y

d)

Error

Incorrect code

8.

PREDICT THE OUTPUT:

int x = 60;

int y = 90;

if (y%x == 0 && y-x==30)

{

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

}

else

{

System.out.println("Error")

}

a)

Hello World

b)

Hello World

Error

c)

Error

d)

Hello world

9.

If a, b and c are the sides of a triangle then which of the following statement is true for:

if(a==b && a==c && b==c)?

a)

Equilateral triangle

b)

Scalene triangle

c)

Isosceles triangle

d)

All of the above

10.

Condition is essentially formed using:

a)

Arithmetic operators

b)

Relational operators

c)

Logical operators

d)

None

11.

Which of the following is a conditional statement?

a)

if

b)

if else

c)

if else if

d)

all of the above

12.

A Java program executes but doesn’t give the desired output. It is due to:

a)

logical error

b)

syntax error

c)

run time error

d)

none

13.

The if -else statement executes a block of code if a specified condition is

a)

true

b)

false

c)

both

d)

none