SET-8
1)public class Application {
public static void
main(String[] args) {
String
one = "Hello";
String
two = "Hello";
if(one
== two) {
System.out.println("one == two");
}
else {
System.out.println("one != two");
}
}
}
A.one == two
B.one != two
C.compile error
D.runtime error
2)Does the following code compile
or not?
interface IFruit
{
public String TYPE =
"Apple";
}
class Fruit implements IFruit
{
}
public class Application {
public static void
main(String[] args) {
System.out.println(Fruit.TYPE);
}
}
A.yes
B.no
3)
public class HelloWorld{
public static void
main(String[] args) {
System.out.println(Math.min(Double.MIN_VALUE, 0.0d));
}
}
A.0.0
B.0.00001
C.Compile error
D.run error
4)
import java.util.*;
public class Test {
public static void
main(String[] args) throws Exception {
char[]
chars = new char[] {'\u0097'};
String
str = new String(chars);
byte[]
bytes = str.getBytes();
System.out.println(Arrays.toString(bytes));
}
}
A.-62, -105
B.0097
C.compile error
D.run error
5)
public class FizzBuzzTest{
public static void
main(String args[]){
for(int
i = 1; i <=10; i++) {
if(i % (3*5) == 0) System.out.println("FizzBuzz");
else if(i % 5 == 0) System.out.println("Buzz");
else if(i % 3 == 0) System.out.println("Fizz");
else System.out.println(i);
}
}
}
A.1 2 Fizz 4 Buzz Fizz 7 8 Fizz
Buzz
B.Fizz Buzz Fizz 7 8 Fizz Buzz
C.Fizz Buzz
D.1 2 3 4 5 6 7 8 9 10
6)TRUE OR FALSE
class BuggyBread {
public static void
main(String[] args)
{
String s2 =
"I am unique!";
String s5 =
"I am unique!";
System.out.println(s2 == s5);
}
}
7)
class BuggyBread2 {
private static int
counter = 0;
void BuggyBread2() {
counter
= 5;
}
BuggyBread2(int x){
counter
= x;
}
public static void
main(String[] args) {
BuggyBread2 bg = new BuggyBread2();
System.out.println(counter);
}
}
A.Compile error
B.Run error
C.5
D.null
8)
public class Test {
public static void main(String[] args) {
foo(null);
}
public static void foo(Object o) {
System.out.println("Object impl");
}
public static void foo(String s) {
System.out.println("String impl");
}
}
A.String impl
B.Object imple
C.compile error
D.run error
9)
long longWithL =
1000*60*60*24*365L;
long longWithoutL =
1000*60*60*24*365;
System.out.println(longWithL);
System.out.println(longWithoutL);
A.31536000000,1471228928
B.12324,56677
C.3153609000,1471228928
D.1245577,324567
10)
public class Testing {
public static void
main(String[] args)
{
// the line below this gives an output
// \u000d System.out.println("comment executed");
}
}
A.comment executed
B.compile error
C.run error
D.none of the above
No comments:
Post a Comment