Q: Select from among the following character escape code which is not available in Java.
A.\t
B.\r
C.\a
D. \\
Correct Option: CExplanation: \a
Q: What will be the output?
public class Test{
public static void main(String args[]){
int a = 42;
double b = 42.25;
System.out.print((a%10)+" "+(b%10));
}
}
A.42 42.5
B.2 2.5
C.4.2 4.225
D.2 4.225
Correct Option: BExplanation: 2 2.5
Q: what will be the output?
public class Test{
public static void main(String args[]){
System.out.print(""=="");
System.out.print(" ");
System.out.print("A"=="A");
System.out.print(" ");
System.out.print("a==A");
}
}
A."==" A"=="A a==A
B.true true false
C.true true a==A
D.Compilation Fails
Correct Option: CExplanation: true true a==A
Q: What will be the output for the below code?
class Test{
public void display(int x, double y){
System.out.println(x+y);
}
public double display(int p, double q){
return (p+q);
}
public static void main(String args[]){
Test test = new Test();
test.display(4, 5.0);
System.out.println(test.display(4, 5.0));
}
}
A.9.0 9.0
B.9 9
C.Compilation Error
D.None of these
Correct Option: CExplanation: Compilation Error
Q: Which of the following is the correct expression that evaluates to true if the number x is between 1 and 100 or the number is negative?
Q: What will be the value of "x" after execution ?
int x = 0, y = 0 , z = 0 ;
x = (++x + y-- ) * z++;
A.-2
B. -1
C.0
D.1
Correct Option: CExplanation: 0
Q: Determine output:
public class Test{
public static void main(String... args){
int a=5 , b=6, c=7;
System.out.println("Value is "+ b + c);
System.out.println(a + b + c);
System.out.println("String " + (b+c));
}
}
A.Value is 67 18 String 13
B.Value is 13 18 String 13
C.Value is 13 18 String
D.Compilation fails
Correct Option: AExplanation: Value is 67 18 String 13
Q: Determine output:
public class Test{
static int i = 5;
public static void main(String... args){
System.out.println(i++);
System.out.println(i);
System.out.println(++i);
System.out.println(++i+i++);
}
}