

MCQOPTIONS
This section includes 22 Mcqs, each offering curated multiple-choice questions to sharpen your Java Programming knowledge and support exam preparation. Choose a topic below to get started.
1. |
The == operator can be used to compare two String objects. The result is always true if the two strings are identical. |
A. | True |
B. | False |
Answer» C. | |
2. |
Objects of a subclass can be assigned to a super class reference. |
A. | True |
B. | False |
Answer» B. False | |
3. |
Objects of a super class can always be assigned to a subclass reference. |
A. | True |
B. | False |
Answer» C. | |
4. |
An individual array element from an array of type int, when passed to a method is passed by value. |
A. | True |
B. | False |
Answer» B. False | |
5. |
An array in the Java programming language has the ability to store many different types of values. |
A. | True |
B. | False |
Answer» C. | |
6. |
Which three are valid declarations of a char? 1.char c1 = 064770; 2.char c2 = 'face'; 3.char c3 = 0xbeef; 4.char c4 = u0022; 5.char c5 = ' iface'; 6.char c6 = ' uface'; |
A. | 1, 2, 4 |
B. | 1, 3, 6 |
C. | 3, 5 |
D. | 5 only |
Answer» C. 3, 5 | |
7. |
public interface Foo { int k = 4; /* Line 3 */ } Which three piece of codes are equivalent to line 3? 1.final int k = 4; 2.public int k = 4; 3.static int k = 4; 4.abstract int k = 4; 5.volatile int k = 4; 6.protected int k = 4;
|
A. | 1, 2 and 3 |
B. | 2, 3 and 4 |
C. | 3, 4 and 5 |
D. | 4, 5 and 6 |
Answer» B. 2, 3 and 4 | |
8. |
Which three are legal array declarations? 1.int [] myScores []; 2.char [] myChars; 3.int [6] myScores; 4.Dog myDogs []; 5.Dog myDogs [7]; |
A. | 1, 2, 4 |
B. | 2, 4, 5 |
C. | 2, 3, 4 |
D. | All are correct. |
Answer» B. 2, 4, 5 | |
9. |
Which four options describe the correct default values for array elements of the types indicated? 1.int -> 0 2.String -> "null" 3.Dog -> null 4.char -> ' u0000' 5.float -> 0.0f 6.boolean -> true |
A. | 1, 2, 3, 4 |
B. | 1, 3, 4, 5 |
C. | 2, 4, 5, 6 |
D. | 3, 4, 5, 6 |
Answer» C. 2, 4, 5, 6 | |
10. |
consider the statement "x = (a > b) ? a : b"; then the value of x is 27, if a = 18 and b = 27. |
A. | True |
B. | False |
Answer» B. False | |
11. |
Whenever the "&&" operator is used, such as in: |
A. | True |
B. | False |
Answer» B. False | |
12. |
The operations y >> 3 and y >>> 3 produce the same result when y > 0. |
A. | True |
B. | False |
Answer» B. False | |
13. |
All bitwise operations are carried out with the same level of precedence in Java. |
A. | True |
B. | False |
Answer» C. | |
14. |
Declarations must appear at the start of the body of a Java method. |
A. | True |
B. | False |
Answer» C. | |
15. |
The modulus operator (%) in Java can be used only with variables of integer type. |
A. | True |
B. | False |
Answer» C. | |
16. |
What is the numerical range of a char? |
A. | -128 to 127 |
B. | -(215) to (215) - 1 |
C. | 0 to 32767 |
D. | D. |
Answer» E. | |
17. |
Which three are valid declarations of a float? 1.float f1 = -343; 2.float f2 = 3.14; 3.float f3 = 0x12345; 4.float f4 = 42e7; 5.float f5 = 2001.0D; 6.float f6 = 2.81F; |
A. | 1, 2, 4 |
B. | 2, 3, 5 |
C. | 1, 3, 6 |
D. | 2, 4, 6 |
Answer» D. 2, 4, 6 | |
18. |
Variables declared inside a for loop are limited in scope to the loop. |
A. | True |
B. | False |
Answer» C. | |
19. |
For the [removed]y >= z && a == b) to be true, at least one of (y >= z) and (a == b) must be true. |
A. | True |
B. | False |
Answer» C. | |
20. |
A break statement must always be present in the default case of a "switch" selection structure. |
A. | True |
B. | False |
Answer» C. | |
21. |
The "switch" selection structure must end with the default case. |
A. | True |
B. | False |
Answer» C. | |
22. |
The [removed]y >= z && a == b) is evaluated by first evaluating the expression y >= z, and then evaluating a == b. |
A. | True |
B. | False |
Answer» C. | |