- APolymorphism
- BInheritance
- CEncapsulation
- DAbstraction
Time Taken:
Correct Answer:
Wrong Answer:
Percentage: %
Inheritance
Reason — Inheritance enables new classes to receive or inherit the properties and methods of existing classes.
logical
Reason — Logical operators operate only on boolean operands and are used to construct complex decision-making expressions. Logical AND && operator evaluates to true only if both of its operands are true.
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.
char check (int x)
Reason — The prototype of a function is written in the given syntax:
return_type method_name(arguments)
Thus, the method has the prototype given below:
char check (int x)
20 22
Reason — The values of strings P and Q are converted into integers using the Integer.parseInt() method and stored in int variables a and b, respectively.
When the statement System.out.println(a + " " + b) is executed, first the operation a + " " is performed. Here, int variable a is converted to a string and a space is concatenated to it resulting in "20 ".
After this, the operation "20 " + b is performed resulting in 20 22 which is printed as the output.
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.
Unboxing
Reason — When an object of a Wrapper class is converted to its corresponding primitive data type, it is called as unboxing.
16 bits
Reason — A char data type occupies 2 bytes in the memory.
1 byte = 8 bits
2 bytes = 8 * 2 = 16 bits
Static method
Reason — Method which is a part of a class rather than an instance of the class is termed as Static method.