May 01

On which lines occur CompilerErrors?

class department {//1

private static String Test1 = “Test1″;//2
final String Test2 = “Test2″; //3

department () {new group(“Test6″,”Test7″);}//4

static class group {//5

final String Test3 = “Test3″;//6
static String Test4 = “Test4″;//7
String Test5=”Test5″;//8

group (final String Test6, String Test7) {//9

System.out.print(Test1); //10
System.out.print(Test2);//11
System.out.print(Test3);//12
System.out.print(Test4);//13
System.out.print(Test5);//14
System.out.print(Test6);//15
System.out.print(Test7);//16

}

}//17

public static void main(String args[]) {//18

new department();//19

}//20

}//21

Antwort/ answer
Tagged with:
Apr 30

What is the Output of the following Code?

public class department {

public static void main(String args [ ]){

group g = new group (){

public String Name() {

return(“abc”);

}

};
group.member gm = new group().new member(){

public String Name() {

return(“def”);

}

};

}

}
class
group {

public String Name (){

return (“ghi”);

}

abstract class member {

public abstract String Name();

}

}


Antwort/ answer
Tagged with:
Apr 16

What is the Output of the following Code?

enum ShopOwner{Mary, Steve, Brian};

class Shop{

public static void main (String args []){

ShopOwner a = ShopOwner.Mary;
String b = new String(“Mary”);

System.out.println(a.equals(“Mary”));
System.out.println(a.equals(b));
System.out.println(a.equals(ShopOwner.Mary));
System.out.println(a==ShopOwner.Mary);

}

}

Antwort/ answer
Tagged with:
Apr 15

What is the output of the following code?

enum ShopNumber{1,2,3};

class Shop{

public static void main (String args []){

ShopNumber a = ShopNumber.1;
System.out.println(a);

}

}

Antwort/ answer
Tagged with:
Apr 14

A Compiler-Error is caused at which line?

enum ShopOwner{ Mary, Steve, Brian}

class Shop{

public static void main (String args []){

ShopOwner a = ShopOwner.Mary;

switch(a){ //1

case “Mary”: System.out.println(“Mary”); //2
case Steve: System.out.println(“Steve”); //3
case ShopOwner.Brian: System.out.println(“Brian”); //4

}

}

}

Antwort/ answer
Tagged with:
Apr 04

What is the output of the following Code?

public class Dog extends Thread{

public void run(){

for (int x = 0; x < 10; x++)

System.out.print(x + ” “);

}

public void start(){}

public static void main(String args[]) {

Dog d = new Dog();
d.start();

}

}

Antwort/ answer
Tagged with:
Apr 03

What is the output of the following code?

class Cat implements Runnable {

public void run () { System.out.println(Thread.currentThread().getName()); }

}

public class Dog {

public static void main(String args[]) {

Cat cat = new Cat();
Thread a = new Thread(cat);
Thread b = new Thread(cat);
a.setName(“Thread a”);
b.setName(“Thread b”);
a.setPriority(2);
b.setPriority(-1);
a.start();
b.start();

}

}

Antwort/ answer
Tagged with:
Mar 03

What is the output of the following code?

Pattern p = Pattern.compile(“\\d*” );
Matcher m = p.matcher(“Test4u21″);
while(m.find()) {
System.out.println(m.start() + ” ” +m.group());

Antwort/ answer
Tagged with:
Feb 12

How many objects will be eligible for garbage collection at the end of the code?

String a = new String(“String1″);
String b = new String(“String2″);
String c = new String(“String3″);
String d = new String(“String4″);

b=a;
c=b;
d=b;

Antwort/ answer
Tagged with:
Feb 11

From which point is one of these objects eligible for garbage collection?

Long a[] = new Long[5];
for (int i = 0; i < a.length; i++) {

Long b = new Long(i);

a[i] = b;

}
System.out.println(“end”);

Antwort/ answer
Tagged with:
preload preload preload
http://www.wikio.de Blog Top Liste - by TopBlogs.de Blogverzeichnis - Blog Verzeichnis bloggerei.de Bloggeramt.de Software
Webbhotell Top Blogs