What can be the test-expression for if in the following program? int a=12,b=21; if(?) { System.Out.Println ("A is largest"); } else { System.Out.Print ("B is largest");
}
a<b
a>b
a!=b
a!<b
Consider the following code
if (number > 0)
System.out.println("Number of positive");
else
System .out.println("Number is Negative");
What will be the output if number is equal to 0?
Number is negative
Number is positive
Both 1 and 2
Number is zero
Which of the following is the general form of a simple 'if ' condition?
if(intialization;test condition;incremented) { statement-block; }
if (test expression) { Statement -block }
if (expression) { Statement -block; }
All of the above
What is a chain of if in which the statement associated with each 'else' is an 'if'?
else if ladder
nested if...else
Switch case statement
Both a and b
Consider the following code Char c='a'; switch(c) { case 'a': System out println("A"); case 'b': System out println("B"); default: System .out.println("c"));
which of the following statement is true for he above code?
Output will be A
Output will be A followed by B
Output will be A,followed by B,and then following C
Will not compile
What will the comparison operators in Java returns?
Boolean value
An integer
depends upon data type
both a and b
How many choices are possible when using a single if else statement.
1
2
3
Many choices
Which of the following control expressions are valid for an if statement?
An integer expression
A boolean expression
either 1 or 2
neither 1 or 2
What is the procedure followed by break statement?
Terminates the whole program.
Terminate the enclosing switch statement.
Execute the appropriate switch statement.
All of them.
Which of the following is the general form of the conditional operator?
expression 1:expression 2?conditional expression;
conditional expression? expression 1 : expression 2;
Conditional expression:expressions?expression2;
All of them