Set – 3
1.public class prg {
public static void
main(String[] args) {
char
a=0x4; //Unicode of 'A'
char
b=0x42; //Unicode of 'B'
System.out.print(a+"" + b+"");
System.out.print("-");
System.out.print(a+b);
}
}
A.B-AB
B.AB-3
C.AB-ERROR
D.A B -3
2.public class prg {
public static void
main(String[] args) {
System.out.println( (byte) 0xff);
}
}
A.-1
B.255
C.65535
D.0xff
3.public class prg {
public static void
main(String[] args) {
System.out.println( (int)(char)(byte) 0xff);
}
}
A.-1
B.255
C.65535
D.0xff
4.class Opr
{
public static void
main(String args[])
{
int
x=5,y;
y= ++x
+ x++ + --x;
System.out.println(x + "," + y);
}
}
A.6,5
B.6,8
C.6,2
D.None of these
5.class Opr
{
public static void
main(String args[])
{
boolean
ans=false;
if(ans=true)
System.out.print("Done");
else
System.out.print("Fail");
}
}
A.Done
B.Fail
C.Error
D.DoneFail
6.class Opr
{
public static void
main(String args[])
{
byte
a,b;
a=0;
b=20;
b=assign(a);
System.out.println(a +","+ b);
}
public static byte
assign(byte a)
{
a+=00;
return
a;
}
}
A.0, 0
B.0, 0
C.0, 0
D.None of these
7.class Opr
{
public static void main(String
args[])
{
int
a,b,result;
a=0;
b=20;
result=(int)(b>=a);
System.out.print(result);
}
}
A.Error
B.True
C.20
8.public class Opr {
public static void
main(String[] args) {
int a=0;
System.out.print((a==true)?
"Hello": "Hi");
}
}
A.Hello
B.Hi
C.Error
D.Null
9.public class Opr {
public static void
main(String[] args) {
System.out.print(0x000A + 0b00 + 0xff);
}
}
A.Error
B.255
C.20ff
D.275
10.class Opr
{
public static void
main(String args[])
{
System.out.print( ((true && true) || false) );
}
}
A.Error
B.false
C.true
D.None of these
No comments:
Post a Comment