Arrays
- Which of these keywords is used to prevent content of a variable from being modified?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
A variable can be declared final, doing so prevents its content from being modified. Final variables must be initialized when it is declared.
- Arrays in Java are implemented as?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
object
- What is the output of this program?
public class Result
{
public static void main(String args[])
{
boolean p = false;
boolean q = true;
boolean r = q ^ p;
System.out.println(!r);
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
output: false
- What is the output of this program?
public class Result
{
public static void main(String args[])
{
int p , q = 2;
p = 20;
if (p != 20 && p / 0 == 0)
{
System.out.println(q);
}
else
{
System.out.println(++q);
}
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Operator short circuit and, &&, skips evaluating right hand operand if left hand operand is false thus division by zero in if condition does not give an error.
output: 3