Computer Applications
What will be the output of the following code?
int size = 2;
if (size < 0)
System.out.println("Small");
else if (size == 0)
System.out.println("Medium");
else
System.out.println("Large");
- Small
- Large
- Medium
- Runtime error
Java Conditional Stmts
31 Likes
Answer
Large
Reason — Since size > 0, hence the conditions of if and else if are false. Thus, the else block will be executed and "Large" will be printed on the screen.
Answered By
11 Likes
Related Questions
Which of the following statements involves a fall through?
- if-else
- for loop
- if-else-if
- switch
Which of the following statement is true for logical errors?
- The compiler does not detect these errors.
- There is no indication of error when the program is executed.
- The program may produce correct results for some input data and wrong results for other input data.
- All of the above
Object oriented programming mainly uses
- top down approach
- top down and bottom up approach
- bottom up approach
- None of the above
In which technique are the values of actual parameters copied to the formal parameters?
- Call by reference
- Call by value
- Call by argument
- Call by method