- AFor
- Bdo...while
- Cwhile
- Dswitch
Time Taken:
Correct Answer:
Wrong Answer:
Percentage: %
Explanation:
The loop starts at i = 5 and decrements by 1 each time.
The if (i % 2 == 1) condition checks if i is odd. If true, it skips the current iteration using continue.
Only even numbers (4 and 2) are printed.
Explanation:
In this loop, the variable i increments by a fixed step (i = i + 5) in each iteration.
Such a loop is called a step loop because it progresses by a specific step val
ue.
Explanation:
The break statement is used to stop the execution of a loop or switch construct.
System.exit(0) stops the entire program, not just a construct.
Explanation:
The this keyword in Java is used within an instance method or constructor to refer to the current object of the class.
Explanation:
In Call by Value, the values of the actual parameters are copied to the formal parameters. Any changes made to the formal parameters do not affect the actual parameters.
Explanation:
words[0] = "Java" → words[0].length() = 4.
words[2] = "fun" → words[2].length() = 3.
Total:
4
+
3
=
7
4+3=7.
Explanation:
parseInt() is a static method of the Integer wrapper class in Java.
It is used to convert a string to an integer.
Explanation:
The charAt(int index) method in the String class is used to extract a character at a specific position (index) in the string.
Java is case-sensitive, so the correct method name is charAt().
Explanation:
Inheritance allows a child class to acquire properties and methods from a parent class, eliminating the need to duplicate code. This promotes code reusability and simplifies maintenance.