Java Module 4 Question Preview (ID: 27919)


Identifiers, Assignment Operators And Numeric Data Type.[print questions]

How would you assign the integer 5 to a variable named numberFive? Assume the variable is already declared
a) numberFive == 5;
b) numberFive = 5;
c) 5 = numberFive;
d) numberFive := 5;

Which of the following is a valid Java variable?
a) 95miles
b) numbers#text
c) final
d) _thisDog

Suppose x is 1. What is x after x += 2?
a) 1
b) 3
c) 4
d) -1

Which of the following contains a valid comment?
a) int twoPi = 2 * 3.14159; /* holds the value of two times pi */
b) int twoPi = 2 * 3.14159; /* holds the value of two times pi //*
c) int twoPi = 2 * 3.14159; /*/ *holds the value of two times pi //*
d) none of the above

To declare an int variable number with initial value 2, you write ___________
a) int number = 2L;
b) integer number = 2;
c) int number = 2.0;
d) int number = 2;

The expression 4 + 20 / (3 - 1) * 2 is evaluated to ______________
a) 4
b) 24
c) 20
d) 9

25 % 1 is _____
a) 1
b) 2
c) 3
d) 0

Which of the following is the correct way to declare a variable?
a) int length width;
b) int length, width
c) int length; width;
d) int length, int width;

What is the result of 45 / 4?
a) 10
b) 11
c) 11.25
d) 12

Which of the following expression results in a value 1?
a) 2 % 1
b) 15 % 4
c) 25 % 5
d) 37 % 6

To declare a constant MAX_LENGTH inside a method with value 99.98, you write
a) final MAX_LENGTH = 99.98;
b) double MAX_LENGTH = 99.98;
c) final double MAX_LENGTH = 99.98;
d) none of the above

Which of the following is a correct name for variables according to Java camel case naming conventions?
a) FindArea
b) findArea
c) findarea
d) FINDAREA

An int variable can hold:
a) 'x'
b) 120.5
c) abc
d) 120

In Java, which of the following is not a numerical type?
a) int
b) char
c) byte
d) double

Before a variable is used it must be _______________
a) defined
b) declared
c) imported
d) assigned

Which of the following is a valid identifier?
a) $total
b) class
c) 8+9
d) 9x

An identifier that cannot be used as a variable name is a ___________________ word
a) special
b) reserved
c) key
d) long

Play Games with the Questions above at ReviewGameZone.com
To play games using the questions from above, visit ReviewGameZone.com and enter game ID number: 27919 in the upper right hand corner or click here.

TEACHERS / EDUCATORS
Log In
| Sign Up / Register