Submitted by c-admin on Fri, 05/31/2019 - 00:08
What will the following class print when executed?
class Test{
static boolean a;
static boolean b;
static boolean c;
public static void main (String[] args){
boolean bool = (a = true) || (b = true) && (c = true);
System.out.print(a + ", " + b + ", " + c);
}
}
Select 1 option
A. true, false, true
B. true, true, false
C. true, false, false
D. true, true, true
Submitted by c-admin on Fri, 05/31/2019 - 00:03
Which of the lines will cause a compile time error in the following program?
public class MyClass{
public static void main(String args[]){
char c;
int i;
c = 'a';//1
i = c; //2
i++; //3
c = i; //4
c++; //5
}
}
Select 1 option
A. line 1
B. line 2
C. line 3
D. line 4
E. line 5
Submitted by c-admin on Fri, 05/31/2019 - 00:00
Which of the following are NOT valid operators in Java?
Select 4 options
A. sizeof
B. <<<
C. instanceof
D. mod
E. equals
Submitted by c-admin on Thu, 05/30/2019 - 23:57
Which of the following statements are true?
Select 2 options
A. The modulus operator % can only be used with integer operands.
B. & can have integral as well as boolean operands.
C. The arithmetic operators *, / and % have the same level of precedence.
D. && can have integer as well as boolean operands.
E. ~ can have integer as well as boolean operands.
Submitted by c-admin on Thu, 05/30/2019 - 23:56
What will be the output of the following program?
public class TestClass{
public static void main(String args[ ] ){
int i = 0 ;
boolean bool1 = true ;
boolean bool2 = false;
boolean bool = false;
bool = ( bool2 & method1(i++) ); //1
bool = ( bool2 && method1(i++) ); //2
bool = ( bool1 | method1(i++) ); //3
bool = ( bool1 || method1(i++) ); //4
System.out.println(i);
}
public static boolean method1(int i){
return i>0 ? true : false;
}
}
Select 1 option
A. It will print 1.
B. It will print 2.
C. It will print 3.
D. It will print 4.
E. It will print 0.
Pages