wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Java Programming Quiz #1

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

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

a)

/ comment /

b)

/* comment */

c)

/ comment */

d)

<-- comment -->

2.

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)

3.

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;

4.

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

a)

int

b)

long

c)

float

d)

double

5.

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;

6.

To output the square root of 25 in Java using the Math static class, the correct code would be:

a)

Math(25 / 2)

b)

Math(25 % 2)

c)

Math.sqrt(25)

d)

new Math.sqrt(25)

7.

What is the problem with this code?

Line 1: String myName = "Mary Jacobson";

Line 2: System.out.println ("My name is " + myname);

a)

Line 2: should be System.out.println ("My name is myName");

b)

Line 2: should be System.out.println ("My name is " ) + myName;

c)

Line 2: should be System.out.display("My name is " + myname);

d)

There is no problem with the code

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