1Q)What is the value displayed in the following program?
class Question {
public static void main(
String[] args) {
int x = 0;
boolean b1,b2,b3,b4;
b1=b2=b3=b4=true;
x=(b1 | b2 & b3 ^ b4) ? x++ : --x;
System.out.println(x);
}
}
A)1
b)2
c)3
D)0
2Q)What is the output of the following program?
class Question {
static int i=1, j=2;
static {
display(i);
}
public static void main(String[] args) {
display(j);
}
static void display(int n) {
System.out.print(n);
}
}
A)1
B)12
C)2
D)4
3Q)1Q)What is the value displayed in the following program?
class Question {
public static void main(String[] args) {
int n = 7;
n <<= 3;<br /> n = n & n+1 | n+2 ^ n+3;<br /> n >>= 2;
System.out.println(n);
}
}
A)0
b)-1
c)14
D)64
4Q)What is the output of the following program?
import java.util.*;
class Question {
public static void main(String[] args) {
HashSet set = new HashSet();
String s1 = "abc";
String s2 = "def";
String s3 = "";
set.add(s1);
set.add(s2);
set.add(s1);
set.add(s2);
Iterator i = set.iterator();
while(i.hasNext()) {
s3 += (String)i.next();
}
System.out.println(s3);
}
}
A)abcdefabcdef
B)defabcdefabc
C)fedcbafedcba
D)defabc
5Q)What output is displayed by the following program?
import java.io.*;
public class TestIOApp {
public static void main(String[] args) throws IOException {
RandomAccessFile file = new RandomAccessFile("test.txt","rw");
file.writeBoolean(true);
file.writeInt(123456);
file.writeInt(7890);
file.writeLong(1000000);
file.writeInt(777);
file.writeFloat(.0001f);
file.seek(5);
System.out.println(file.readInt());
file.close();
}
}
A)123456
B)7890
C)1000000
D)777
E).0001
6Q)What is the value of -31>>>5>>5>>>5>>5>>>5>>5?
A)NaN
B)-1
C)3
D)1024
7Q)What is the output of the following program?
import java.util.*;
class Question {
public static void main(String[] args) {
TreeMap map = new TreeMap();
map.put("one","1");
map.put("two","2");
map.put("three","3");
displayMap(map);
}
static void display(TreeMap map) {
Collection c = map.entrySet();
Iterator i = c.iterator();
while(i.hasNext()) {
Object o = i.next();
System.out.print(o.toString());
}
}
}
A)123
B)onetwothree
C)one=1three=3two=2
7Q)What line of output is displayed by the following Program?
class Question {
static boolean sideEffect(boolean b) {
System.out.print("sideeffect");
return b;
}
public static void main(String[] args) {
boolean b1 = true;
boolean b2 = false;
if(b2 & sideEffect(b1))
System.out.println(1);
if(b1 & sideEffect(b2))
System.out.println(2);
}
}
A)1
B)2
C)sideeffect1
D)sideeffect2
E)sideeffectsideeffect1
F)sideeffectsideeffect2