- Anext()
- BnextLine()
- CNext()
- DnextString()
Time Taken:
Correct Answer:
Wrong Answer:
Percentage: %
nextLine()
Reason — nextLine() reads the input till the end of line so it can read a full sentence including spaces.
import
Reason — import keyword is used to import built-in and user-defined packages into our Java program.
4.0
Reason — Math.ceil method returns the smallest double value that is greater than or equal to the argument and Math.sqrt method returns the square root of its argument as a double value. Thus the given expression is evaluated as follows:
Math.sqrt(Math.ceil (15.3))
= Math.sqrt(16.0)
= 4.0
break
Reason — The absence of break statement leads to fall through situation in switch case statement.
concat(String)
Reason — concat() method is used to join two strings. Its syntax is as follows:
String1.concat(String2)
POS
Reason — The substring() method returns a substring beginning from the startindex and extending to the character at endIndex - 1. Since a string index begins at 0, the character at index 3 is 'P' and the character at index 5 (6-1 = 5) is 'S'. Thus, "POS" is extracted.
explicit
Reason — In explicit type conversion, the data gets converted to a type as specified by the programmer. Here, the float value 32.8 is being converted to int type by the programmer, explicitly.
java byte code
Reason — Java compiler converts Java source code into an intermediate binary code called Bytecode after compilation.
20
40
Reason — Since n = 10, case 10 will be executed. It prints 20 (10 * 2) on the screen. Since break statement is missing, the execution falls through to the next case. Case 4 prints 40 (10 * 4) on the screen. Now the control finds the break statement and the control comes out of the switch statement.
16 bits
Reason — A char data type occupies 2 bytes in the memory.
1 byte = 8 bits
2 bytes = 8 * 2 = 16 bits