Syvum Home Page

Home > Quiz Games > Java Programming > Print Preview

Java Programming : Language Basics : True or False

Formats Info Page Worksheet / Test Paper Quiz Review
Table

Try the Quiz : Java Programming : Classes : True or False

About Button apid Just what you need to know!
eview

QuestionAnswerExplanation
The modulus operator (%) in Java can be used only with variables of integer type.
• True
• False
FalseThe modulus operator (%) may be used with floating-point as well as integer types. It returns the remainder of a division operation, e.g., 10 % 6 will return 4.
Declarations must appear at the start of the body of a Java method.
• True
• False
FalseThey can appear anywhere within the body of the method.
All bitwise operations are carried out with the same level of precedence in Java.
• True
• False
FalseAll operations in Java, including the bitwise operations, are carried out with a definite precedence.
The operations y >> 3 and y >>> 3 produce the same result when y > 0.
• True
• False
TrueThe shift operation "y1 >>> y2" is identical to "y1 >> y2" for all positive values of y1. It shifts the bits in y1 to the right by y2 positions.
consider the statement "x = (a > b) ? a : b"; then the value of x is 27, if a = 18 and b = 27.
• True
• False
Truethe statement is equivalent to: if (a > b) x = a; else x = b;
Whenever the "&&" operator is used, such as in:
exp1 && exp2
where exp1 and exp2 are boolean expressions, both the boolean expressions are not always evaluated.
• True
• False
TrueIf the first expression is false, the result of the "&&" operation will always be false regardless of the second expression. The "&" operator on the other hand forces the evaluation of the second expression even if the first expression is false.
The expression (y >= z && a == b) is evaluated by first evaluating the expression y >= z, and then evaluating a == b.
• True
• False
FalseIf y >= z is false, then there is no need to evaluate the second expression.
The "switch" selection structure must end with the default case.
• True
• False
FalseThe default case in a switch structure is optional and only used when none of the other cases match.
A break statement must always be present in the default case of a "switch" selection structure.
• True
• False
FalseThe break statement, which brings the computation out of the "switch" selection structure, is not required for the defalut case.
For the expression (y >= z && a == b) to be true, at least one of (y >= z) and (a == b) must be true.
• True
• False
FalseFor the result of a "&&" operation to be true, both operands must be true.
Variables declared inside a for loop are limited in scope to the loop.
• True
• False
FalseAny variable declared within a block statement such as a for or if cannot be referenced outside the block.
An array in the Java programming language has the ability to store many different types of values.
• True
• False
FalseAll elements of an erray must be of the same type. However, it is possible to declare an array of objects, which may of instances of different classes.
An individual array element from an array of type int, when passed to a method is passed by value.
• True
• False
TrueIndividual elements of an array of this type are passed by value as a parameter to a method. Any changes to them in the method will not change the value of the array element.
Objects of a super class can always be assigned to a subclass reference.
• True
• False
FalseObjects of a subclass may be assigned to a super class reference. Food for thought: is there a loss in functionality when this is done?
Objects of a subclass can be assigned to a super class reference.
• True
• False
TrueObjects of a super class may not be assigned to a sub class reference. Food for thought: why is it so?
The == operator can be used to compare two String objects. The result is always true if the two strings are identical.
• True
• False
FalseString objects must be compared using the "equals" method of one of the objects. Food for thought: will the == operator ever return true when two string objects are compared using it?

Try the Quiz : Java Programming : Classes : True or False


Contact Info © 1999-2024 Syvum Technologies Inc. Privacy Policy Disclaimer and Copyright
Previous
-
Next
-