WWW.SCJPSCHOOL.COM By KAIRO  
  SCJP   ڷ By    
 
   

     
     


١١1.Which will declare a method that forces a subclass to implement it?

a. public double()
b. abstract public void methodA()
c. final abstract public void methodB()
d. static abstract public void methodC()




 : b



١١2. which two statement are there coding the creation of a default constructor?(choose two)

a. The default constructor initializers method vaiables.
b. The default constructor invokes the no parameter constructor of the superclass.
c. The default constructor initializers the instance variable declared in the class.
d. if a class lacks a no parameter constructor but has other constructors the compiler creates a default constructor.
e. The compiler creates a default constructor only where there are a other constructor for the class.




 : b,c - e 1 ٸ ڰ ִ  Ʈ ڸ ٴ ̹Ƿ Ʋϴ.
       Ʈ ڴ class ٸ ڰ  쿡 Ϸ մϴ.                   



3. Which will declare a method that is a varilable to all members of the same package and can be referenced without an instance of the class?

a. abstract public void methoda()
b. public abstract double methoda() 
c. static void methoda(double d1) 
d. public double methoda() 
e. protected void methoda() 




 : c



4. Which two declation prevent the overriding of a method?(choose 2)

a. final void methoda() 
b. void final methoda() 
c. static void methoda()
d. static final void methoda() 
e. final abstract void methoda() 
 



 : a,d



5. Which declaration prevents creating a subclass of an outer class?

a. static class FooBar()
b. private class FooBar()
c. abstract class FooBar()
d. final public FooBar()
e. final abstract FooBar()




 : d



6.
calss Super{
    public float getNum(){return 3.0f;}
}

public class Sub extends Super{
    //point here
} 

a. public float getNum(){ return 4.f;}
b. public void getNum(){return 4.0f;}
c. public void getNum(double d){};
d. public double getNum(float d){ return 4.0d;}




 : a,c,d



7. 
public class Test{
    public int aMethod(){
        static int i=0;
        i++;
        return i;
    }

    public static void main(String[] args){
        Test test = new Test();
        test.aMethod();
        int j = test.aMethod();
        System.out.println(j);
    } 
} 

what result? 

a. compile will fail
b. compile will success and print "0"
c. compile will success and print "1"
d. compile will success and print "2"




 : a - static ޼ҵ ȿ ڵ   .



١١١8.
import java.io.IOException;

public class ExceptionTest{
    public static void main(String[] args){
        try{
            methodA(); 
        }
        catch(IOException io){
            System.out.println("caught IOException");
        }
        catch(Exception e){
            System.out.println("caught Exception");
        }
    } 

    public static void methodA(){
        throw new IOException();
    } 
} 

what result?

a. The code will not compile
b. Output is "caught Exception"
c. Output is "caught IOException"
d. The program execute nomally without print a message




 : a  - public static void methodA(){  //throws Excepton


9. 
public class Foo{
    static String s;
    public static void main(String [] args){
        System.out.println("s= " +s);
    } 
}



a. The code compiles and "s = " is printed
b. The code compiles and "s = null" is printed
c. The code does not compile because Strings is not initialized
d. The code does not compile because Strings can not be referenced
e. The code compiles but a NullPointerException is throw when to String is called




 : b



١١10. 
public class Foo{
    public static void main(String args[]){
        String s;
        System.out.println("s = " + s);
    } 
}

? 

a. code does not compile because String s is not initialized
b. code compile and "s = " is printed
c. code compile and "s = null" is printed
d. code compiles, but a NullpointException




 : a (ڹ2page112: ʱȭ)



١١11. What is result? ()
public class x{
    private static int a;                

    public static void main(String[] args){
        modify(a);
        System.out.println(a);
    } 

    public static void modify(int a){ 
        a++;
    }
} 




 : 0 µ. - a++; //a local   by ,,moon,ڹ,ȫ
 



12. 
public class Test{ 
    public static void leftShift(int i, int j){ 
        i<<=j;
    } 

    public static void main(String args[]){ 
        int i = 4, j = 2;
        leftShift(i,j);
        System.out.println(i);
    } 
}

What's the result?

a. 2   
b. 4 
c. 8 
d. 16 
e. not compile




 : b



13.
public class ReturnIt{
    returntype method A(byte x, double y){
        return (short)x/y*2;
    }
}

a. int 
b. byte 
c. long 
d. short 
e. float 
f. double




 : f



14. 
1: public class ReturnIt{
2:     returnType methodA(byte x, double y){ 
3:         return (long)x/y*2;
4:    }
5:}

What is the valid returnType for methodA in line 2?

a. int 
b. byte 
c. long 
d. short 
e. float 
f. double




 : f



١١١15.
1: abstract class AbstractIt{
2:     abstract float getFloat();
3: }
4: public class AbstactTest extends AbstractIt{
5:     private float f1 = 1.0f;
6:     private float getFloat() { return f;}
7:} 

what result??

a. compile will success
b. An error at line 6 cause compile to fail
c. An error at line 4 cause compile to fail
d. An error at line 2 cause compile to fail




 : b



16.
public class Foo{
    public static void main(String[] args){
        try{ return;}
        finally { System.out.println("Finally"); }
    }
} 

what result?

a. Print nothing
b. Print "Finally"
c. Not compiled and will Exception thrown
d. Not compile because catch block missing




 : b



17. 
public class Test {
    public static void main(String [] args){ 
        try{ System.exit(0);}
        finally{  System.out.println("Finally");}
    }
} 

What is the result?

a. The program runs and prints nothing
b. The program runs and prints "Finally"
c. The code compiles but an exception is thrown at runtime
d. The code code will not compile because the catch block is missing




 : a  -  System.exit(0);}//finally Ѵ..



18. 
public static String output = "";

public static void foo(int i){
    try{
        if( i == 1 )
            throw new Exception();
        output += "1";
    }catch(Exception e){
        output += "2";
        return;
    }
    finally{ 
        output += "3";
    }
    output + = "4";
}

public static void main(String args[]){
    foo(0);
    foo(1);
 // point y
} 

point y   output variable value? ()




 : 13423



19. 
int i=1, j=10;        
do{
   if(i++ > --j) continue;
}while(i<5);
   System out println("i:"+i+"j:"+j);

츮  ߴ ..̰͵ 
ְ ..




 : i:5j:6 



١١20. 
public class ForBar { 
public static void main(String[] args){ 
    int i=0, j=5;
tp: 
    for(;;i++)       
       for(;;--j)
           if(i>j) break tp;
             System.out.println("i = "+i+"j = "+j);
    }
}

What is the result? ()




 : i = 0j = -1



21. 
public class Test{
    public static void main(String [ ] args){ 
        for1: for(int i=0; i<3; i++) {
           for2: for(int j=0; j<2; j++) { 
              if(i==1 && j==0) 
                break for1; 
              if(i==2 && j == 1) 
               continue for2;
            System.out.println("i= " +i+"j= " +j);
           } 
        } 
    }
}

What is the output?




 : i=0j=0 i=0j=1



١١22. 
int i = 0;
int j = 5;

tp : for( ; ; ){
    i++;
    for( ; ; )
        if( i>--j )
            break tp;
}

System.out.println("i :" + i + "j :" + j )

? ()




 : i:1j:0



23. 
int i = 1;
int j = 0;

switch(i){
  case 2 : j+=6;
  case 4 : j+=1;
  default : j+=2;
  case 0 : j+=4;
} 
//point x

point x ̺κп j? ()




 : 6



١١24. int i = 1;
int j = 10;
do {
    if( i>j )
    break;
     j--;
}
while( ++i < 5 ); 

 i & j ? (; & Ʈ Ǯּ.)




 : 4  (i=5, j=6̹Ƿ)



١١25.
1: public class X{
2:     public Object m(){
3:         Object o = new Float(3.14f);
4:         Object [ ] oa = new Object[1];
5:         oa[0] = o;
6:         o = null;
7:         return oa[0];
8:    }
9:}

When is the Float Object create in line 3, eligible for Garbage Collection?

a. just after line 5
b. just after line 6
c. just after line 7(that is as the method returns)
d. never in this method




 : d



 Ŭ  ?  (System.out.println(oa[0]);)




 : 3.14



١١١26.
1: public class x{
2:     public Object m() {
3:         Object o = new Float(2.14f);
4:         Object [] oa = new Object[1];
5:         oa[0] = o;
6:         o = null;
7:         oa[0] = null;
8:         return o;
9:    }
10:}

When is the Float object created in line? eligible for garbage collection?

a. just after line 5
b. just after line 6
c. just after line 7
d. just after line 8(that is as the method returns)




 : c



 Ŭ  ?(System.out.println(o);)




 : null



27. 
public class Test{
    public static void main(String[] args){
        String foo = args[1];
        String bar = args[2];
        String baz = args[3];
    }
} 

shell command : java Test red green blue

<>  ְ غ..
  ..




 : ArrayIndexOutOfBoundsException ߻.



28.Which three are valid declare of a float(Choose three.?

a. float foo = -1;
b. float foo = 1.0;
c. float foo = 42e1;  
d. float foo = 2.02f;
e. float foo = 3.03d;
f. float foo = 0x0123;




 : a,d,f    
       b,e - double   
       c. float foo = 42e1;   //Ѿ  



29. 
public static void main(String args[]){
    String foo = args[1];
    String bar = args[2];
    String baz = args[3];
    System.out.println("baz = " + baz);
}

 baz = 2 ̴

command line invocation will produce the output?

a. java Test 4 2 4 2
b. java Test 4 3 2 1
c. java Test 2222




 : a



30. 
//point x
public class Foo{
    public static void main(String[] args) throws Exception {
        PrintWriter out = new PrintWriter(new java.io.OutputStreamWriter(System.out),true);
        out.println("Hello");
    }
}

What statement need to "point x " to success compile?

a. import java.io.PrintWriter;
b. include java.io.PrintWriter;
c. import java.io.OutputStreamWriter;
d. Include java.io.OutputStreamWriter;
e. No statement need




 : a  -> need to



١١31. 
// point x
public c Foo{
    public static void main(String[] args){ 
        java.io.PrintWriter out = new java.io.PrintWriter(new java.io.OutputStreamWriter(System.out,true);
        out.println("Hello");
    }
}

Which point x on line 1 allows this code to compile and run?

a. import java.io.*;
b. include java.io.*;
c. import java.io.PrintWriter;
d. include java.io.PrinrWriter;
 



 : a,c  -> allows 



32. byte[] array1,array2[];  
byte array3[][];
byte[][] array4; 

if each array has been initialized which statement will error?

a. array2 = array1;
b. array2 = array3;
c. array2 = array4;
d. both a and b
e. both a and c
f. both b and c




 : a  -   byte[] array1,array2[];  //array2[][]  



١١33. Which two statement be class a variable foo, capable of reference an array of 10 ints? (choose two)

a. int[] foo;
b. int foo[];
c. int foo[10];
d. Object[] foo;  
e. Object foo[10];




 : a,b - d. Object[] foo;  //⺻   



١١١34. 
String foo = "blue";
boolean[] bar = new boolean[1];
if(bar[0]) 
    foo="green";
 
What is the result?

a. foo has the value of ""
b. foo has the value of null
c. foo has the value of "blue"
d. foo has the value of "green"
e. An Exception is thrown
f. The code will not compile




 : c



١١35. 
int index = 1;
String[] test = new String[3];     
String[] foo = test[index];

what is the result?

a. foo has the value ""
b. foo has the value null
c. An exception is thrown
d. The code will not compile




 : d 
       String foo = test[index];̸ null .....



١١36.
public class Test{
    public static void stringReplace(String text){
        text = text.replace('j','1');                         
    }
    public static void bufferReplace(StringBuffer text){
        text = text.append("c");
    }

    public static void main(String[] args){
        String textString = new String("java");                         
        StringBuffer textBuffer = new StringBuffer("java");
        stringReplace(textString);
        bufferReplace(textBuffer);

        System.out.println(textString+textBuffer);
    }
}

<> What result?




 : javajavac       
       String textString = new String("java");   //String  Һ StringBuffer 
 


١١37.
public class Test{
    public static void add3(Integer i){
        int val = i.intValue();   
        val += 3;                    
        i = new Integer(val);  
    }

    public static void main(String[] args){
        Integer i = new Integer(0);
        add3(i);
        System.out.println(i.intValue());
    }
} 

What result?

a. compile fail
b. The program print "0"
c. The program print "3"
d. Compile success but Exception thrown at line 3




 : b
       add3 i  ϵ Ͽ 0 Ʈ.
       add3 println  3 ȣ.
       int val = i.intValue();   //0 i
       val += 3;                    //0+3 



١١38.
public class Foo{
    public static void main(String[] args){
        StringBuffer a = new StringBuffer("A");
        StringBuffer b = new StringBuffer("B");
        operate(a,b);
        System.out.println(a + "," + b);
    }

    static void operate(StringBuffer x,StringBuffer y){
        x.append(y); 
        y = x;
    }
}

What print?

a. "A,B" 
b. "A,A" 
c. "B,B"
d. "AB,B" 
e. "AB,AB" 
f. "A,AB"

 


 : d 
        -> y.append(x); x=y;  . ׷"A,BA"ǰ



١١39. what is the result?()
public class Test{
    static void replaceJ(String text) {
        text.replace('j','i');
    }

    public static void main(String [] args) {
        String text = new String("java");
        replaceJ(text);
        System.out.println(text);
    }
}




 : java



١١40. Object []foo = new Object[1];
Object bar = foo[0];
String baz = bar.toString();

baz ?




 : NullPointerException ߻



١١41. 
float f = 4.2f;
Float g = new Float(4.2f);
Double d = new Double(4.2); 

Which two express equivalent to true? (⿡  ϳۿ )

a. (f == g) 
b. (d == f) 
c. ( g == g)
d. (d.equals(f)) 
e. (d.equals(g)) 
f. (g.equals(4.2)




 : c       //e Ʋ.    



١١42.
public class Test{
    private static int j = 0;
    public static boolean methodB(int k){
        j += k;
        return true;
    }

    public static void methodA(int i){
        boolean b;
        b = i < 10 | methodB(4);
        b = i < 10 || methodB(4);
    }

    public static void main(String[] args){
        methodA(0);
        System.out.println(j);
    }
}

What result?

a. print "0" 
b. print "4" 
c. print "8"
d. print "12" 
e. The code dose not compile
 



 : b



١١١43.
package foo;
public class Outer{
public static class Inner
}

Which statement true? 

a. An instance of the Inner class can be constructed statement with "new Outer.Inner()"
b. An instance of the Inner class can't be constructed outside of package foo
c. An instance of the Inner class can only be constructed from within the Outer class
d. From within the package bar, an instance of the Inner class can be constructed statement with "new Inner()"




 : a



١١44.
1: class EnClosingOne{
2:     public class InsideOne{
3:     } 
4:     public class InnerTest{
5:         public static void main(String[] args){
6:             EnClosingOne eo = new EnClosingOne();
7: // insert code here!
8:         }
9:     }
10:}     

Which statement at line 7(// inset code here!) construct of inner class?

a. InsideOne ei = eo.new InsideOne();
b. eo.InsideOne ei = eo.new InsideOne();
c. InsideOne ei = EnClosingOne.new InsideOne();
d. EnClosingOne ei = new eo.new InsideOne();
 



 : b



١١45. 
1: public class Outerclass{ 
2:     private double d1 = 1.0;
3: // insert code here
4:}

You need to insert an inner class declaration at line3 which two inner class declarations are vaild? (choose two )

a. static class InnerOne{
        public double methoda(){
             return d1;
        }
    }

b. private class InnerOne{
        public double methoda(){
            return d1;
        }
    }
c. protected class InnerOne{
        static double method(){
            return d1;
        } 
    }
d. public abstract class InnerOne{
        public abstract void methoda();
    }




 : b,d( ̻!!!!!b Ȯ .׷ϱ  b,?ϰͰ,   Ȯ  !)       
      - d Ȯ 
      a. static class InnerOne   //static  class d1 static valiable access   
      c. protected class InnerOne  //static ȿ d1       



١١46. 
1: public class Outer Class {
2:     private double d1 = 1.0;
3: //insert code here
4: }

You need to insert an inner class declation at line 3 which two inner class declation are valid?

a. static class InnerOne {
        public double method() { return d1;}
    }
b. static class InnerOne {
        static double method() { return d1;}
    }
c. private class InnerOne {
        public double method() { return d1;}
    }
d. protected class InnerOne {
        public abstract double method() { return d1;}
    } 
e. public abstract class InnerOne {
        public abstract double method();
    }




 c,e



١١47. Which statement about static inner classes are true?(choose two)

a. static inner class requires a static initialize
b. static inner class requires an instance of the enclosing class
c. static inner class has no reference to an instance of the enclosing class
d. static inner class has to the non static members of the outer class
e. static members of a static inner class can be referenced using the class name of the static innner class




 : c,e



١١48. which two statements are true (two)

a. An inner class may be declared as static
b. An annonymous inner class can be declared as public
c. An annonymous inner class can be declared as private
d. An annonymous inner class can extend an abstract class
e. An annonymous inner class can be declared as protected




 : a,d



١١49.
public class MethodOver{
    public void setVar(int a, int b, float c);
}

Which two overload the setVar method ? (choose two)

a. private void setVar(int a, float c, int b);
b. protected void setVar(int a, int b, float c);              
c. public int setVar(int a, float c, int b)return a;
d. public int setVar(int a, int b, float c)return a;
e. protected final setVar(int a, int b, float c)return c;
 



 : a,c  - //overload acssase modifier returntype  .



50. 
1: public class ExceptionTest{
2:         class TestException extends Exception {}
3:          public void runTest() throws TestException
4:          public void test() /* point x */ {
5:              runTest();
6:        }                             
7:}

At point x on line 4, which code can be added to make the code compile?

a. throws Exception
b. catch Exception e
c. throws RuntimeException
d. catch(TestException e)
e. No code is necessary




 : a -  //runTest() Ͽ  exception runTest()  test() ش.



١١51. under which conditions will check() return true when called from a different class?
 
public class SynchTest{
    private int x;
    private int y;
    private synchronized void setX(int i){x = i;}
    private synchronized void setY(int i){y = i;}
    public void setXY(int i){ setX(i); setY(i);}

    public synchronized boolean check(){
        return x!=y;
    }
}

a. check() can never return true
b. check() can return true when setXY is called by multiple threads
c. check() can return true when multiple threads call setX and setY separately
d. check() can only return true if SynchTest is changed to allow x and y to be set separately
 



 : a,d   ְ b  ִ  -> c   ..
   b : Ǫٶ(п..),,ڹ ʺ
   setXY synchronized ɷ setX setY  ʴ  ҿ  // by 
    x, y  ޼ҵ setX(), setY() private ̱⶧ ٸ Ŭ ȣ   // by ڹ ʺ




١١١52. 
1: class A implements Runnable {
2:    int I;
3:    public void run () {
4:        try {
5:             Thread.sleep(5000);
6:             i=10; 
7:        }catch(InterruptedException e) {}
8:    }
9:}
10:
11: public class Test {
12:    public static void main (String args[]) {
13:         try {
14:             A a = new A();
15:             Thread t = new Thread(a);
16:             t.start();
17: 
18:             int j= a.i;
19:        }
20:        catch (Exception e) {}
21:    }
22:}


Which statement at line 17 will ensure that j=10 at line 19

a. a.wait(); 
b. t.wait(); 
c. t.join(); 
d. t.yield();
e. t.notify(); 
f. a.notify(); 
g. t.interrupt();


 

 : c -   join()   //thread  main() BLOCKŴ



53. Which two can be used to create a new Thread (Choose two)?

a. extend java.lang.Thread & override the run method
b. extend java.lang.Runnable & override the start method
c. implements java.lang.Thread implements run method
d. implements java.lang.Runnable implements run method
e. implements java.lang.Thread implements start method




 : a,d



54. 
class A extends Thread{
    private static int j=2;
    public synchronized void run(){
        j*=2;
        j/=2;
    }
}

public class Test{
    public static void main(String args[]){
        Thread t1 = new A();
        t1.start();
        Thread t2 = new A();
        t2.start();
    }
}

?

a. The value of j could never be 8
b. an error at line 3 cause come to fail
c. t1.run() and t2.run() may execute concurrently
d. t1.run() will definitely return before t2.start() is called
 



 : a



١١55. 
1: public class X implements Runnable{
2:     public int x;
3:     public int y;
4:     public void run(){
5:         for( ; ; ) {
6:             x++;
7:             y++;
8: //point x 
9:             System.out.println("x: " + x + "y: " + y);
10:       }
11:   }
12:}

which two changes together ensure that the values of x and y printed at point x will always be equal, and will increment by one for each line of output, regardless of how many threads access a single instance of the X class concurrently ?

a. run method synchronized...
b. make the member variable(x and y) as private
c. add a synchronized block surrounding the increment operation on line 6 & 7




 : a 
      b ̶׿.( by ʺ, ް)



١١56. 
public class Foo implements Runnable{
    public void run(){
        System.out.println("Running");
    }
    public static void main(String args[]){
        new Thread(new Foo()).start();
    }
}

Which two cannot directly cause a thread to stop executing (choose two) ?

a. calling yield method on an object
b. calling wait method on an object
c. calling notify method on an object
d. calling notifyAll method on an object
e. calling the start method on another Thread object




 : c,d  (e)



١١57. Which two can diretly cause a thread to stop executing(choose 2)

a. exiting from a synchronized block
b. calling the wait method on an object
c. calling the notify method on an object
d. calling the notifyAll method on an object
e. calling the setPriority method on a thread object
 



 : b,e



١١58. Which can be used to decode char s for input?

a. java.io.InputStream
b. java.io.EncodeReader
c. java.io.InputStreamReader       
d. java.io.InputStreamWriter
e. java.io.BufferedInputStream
 



 : c   - or OutputStrieamWriter



١١59. Which constructs a DataInputStream?

a. new DataInputStream("input.text");
b. new DataInputStream(new File("input.txt"));
c. new DataInputStream(new FileReader("input.txt"));
d. new DataInputStream(new InputStream("input.txt"));
e. new DataInputStream(new FileInputStream("input.txt"));




 : e



١١60. Which gets the name of the parent directory of file "file.txt"?

a. String name = File.getParentName("file.txt")
b. String name = (new File ("file.txt").getParent());
c. String name = (new File ("file.txt").getParentName());
d. String name = (new File ("file.txt").getParentFile());
e. Directory dir = (new File ("file.txt").getParentDir());
f. String name = dir.getName();




 : b



61. How can you create a listener class that receives event when the mouse is moved?

a. by extending MouseListener
b. by implementing MouseListener
c. by extending MouseMotionListener
d. by implementing MouseMotionListener
e. either by extending MouseMotionListener or extending MouseListener
f. either by implementing MouseMotionListener or implement MouseListener




 : d



١١62. Which type of event indicate a key pressed on a java.awt.component?

a.keyEvent 
b.keyDrawEvent 
c.keyPressEvent 
d.keyTypedEvent 
e.keyPressedEvent




 : a


63. Which two interfaces provied the capability to store objects using a key value pair?(choose 2)

a. java.util.Map
b. java.util.Set
c. java.util.List
d. java.util.SortedSet
e. java.util.SortedMap
f. java.util.Collection




 : a,e



١١64. Which interface does java.util.Hashtable implement?

a. java.util.Map
b. java.util.List
c. java.util.Hashable
d. java.util.Collection
 



 : a



١١65. 
class Super{
    public int i=0;
    public Super(String text){
        i = 1;
    }
}

public class Sub extends Super{
    public Sub(String text){
        i = 2;
    }

    public static void main(String[] args){
        Sub sub = new Sub("Hello");
        System.out.println(sub.i);
    }
}

whar result?

a. compile will fail
b. compile will success & print "0"
c. compile will success & print "1"
d. compile will success & print "2"
 



 : a  (θŬ Ʈ ڰ   ߻)



١١66.Which two are reserved word in java?

a. run 
b. import 
c. default 
d. implements




 : b,c,d  



67. 
int index = 1;
boolean[] test = new boolean[3];
boolean foo = test[index];
 
What is correct?

a. foo has the value of
b. foo has the value of null
c. foo has the value of true
d. foo has the value of false
e. Exception thrown




 : d



١١68.
1: public class Test{
2:     public static void main(String[] args){
3:         int i = 0xFFFFFFF1;                           
4:         int j = ~i;                                       
5:    }
6: }

What is the decimal value of a line 5 ?

a. 0 
b. 1 
c. 14 
d. -15
e. A error at line 3 cause compile to fail
f. A error at line 4 cause compile to fail




 : c
       int i = 0xFFFFFFF1;   // 1111 1111 0001
       int j = ~i;              // 0000 0000 1110



١١١69. What is the output?
class Super {
    public Integer getLength()  { return new Integer(4);}
}

public class Sub extends Super{
    public Long getLength()  { return new Long(5);}

    public static void main(String [] args) {
        Super super1 = new Super();
        Sub sub = new Sub();
        System.out.println(super1.getLength().toString() + "/" +sub.getLength().toString());
    }
}




 :  (̵ ߸)




١١70.Which declaration prevent creating a SubClass of a OuterClass?

a. static class FooBar
b. private class FooBar
c. abstract class FooBar
d. final public class FooBar
e. final abstract class FooBar
 



 : d




ڡڡڡ71. Which four types of objects can be thrown using the throw statement?(choose four)

a. Error     
b. Event
c. Object
d. Exception
e. Throwable 
f. RuntimeException




 : a,d,e,f
       a. Error     //Throwable ٷ ü 
       e. Throwable  //ֻ ü



---------------------------------------------------------------------------------------------------------------------------------------------------------


72. What is the numerical range of a char? ()




 : 0 ~ 2^16 -1(2 16 - 1)//65535



١١73. 
1: public class SuperClass {}
2: class SubClassA extends SuperClass {}
3: class SubClassB extends SuperClass {
4:     public void test(SubClassA foo) {        
5:         SuperClass bar = foo;                          
6:     }
7: }

which statement is true about the assingnment in line 5?

a. the assingment in line5 is illegal and will not compile
b. the assingment legal, but might throw a ClassCastException at runtime
c. The assingment is legal and will always exeute without throwing an exception
d. the assingment is legal and the code will compile, but will always throw an exception at runtime




 : d
          public void test(SubClassA foo)         //(SuperClass foo)̰ 
          SuperClass bar = foo;                  //SubclassB bar=(subClassb.foo;   ϶
           



ڡڡڡ74. 
public class Test{
    public static void leftShift(int i, int j){
        i<<=j;
    }

    public static void main(String[] args) {
        int i = 4, j=2;
        leftShift(i,j);
        System.out.println(i);
    }
}

What if the result?

a. 2
b. 4
c. 8
d. 16
e. not compile
 



 : b(i   ʴ´.)



١١75. Which two demonstrate encapsulation of data? (choose two)

a. Member data have no access modiffiers
b. Member data can be modified ditectly
c. The access modifier for methods is protected
d. The access modifier to member data is private
e. Methods provide for access an modification of data
 



 : d,e



76. switch(i) i ü ִ data type?

a. byte
b. long
c. float
d. double
e. byte & long
f. float & double




 : a(i ݵ  ;Ѵ.׷ long int ũ)



١١77. Test.java public class Ѱ.
  illegal  ?

a. package foo;
b. import java.io.*;
c. public class Test  
d. public class Bar  
e. public int i;
 



 : d,e



78. short numerical range?




 : (-32768 ~ 32767)



79. char numerical range? 




 : ( 0 ~ 65535 )



١١80. 
public class Foo{
    public static int main(String[] args){
        System.out.println("Hello World");
        return;
    }
}

What is result?

a. An exception
b. The code not compile
c. An exception is thrown




 : b  - int Լ return  .



١١81. 
public class Foo {
    public static int main(String args[]) {
        System.out.println("Hello World");
        return 0;
    }
}

What's the result?

a. An exception is thrown
b. The code does not compile
c. "Hello World" is printed to the terminal
d. The program exits without printing anything




 : a
      ( return 0; Ѵٸ   )



١١82. value  natural order no duplicate...




 : sortedSet



١١١83. You want to limit access to a method of a public class to members of the same class. Which access modifiier is right?

a.public 
b.private 
c.protected 
d. --- 
e.No access modifier is required




 : b (̺ page127)



١١84. You want a class to have access to member of another class in the same package. Which is the most restrictive access modifier that will accomplish this obejctive?

a.public 
b.private 
c.protected 
d. -----
e.No access modifier is required




 :e (̺ page127)



١١١85.
1: class A{
2:     public int getNumber(int a){
3:         return a +1;
4:    }
5:}
6: class B extends A{
7:     public int getNumber(int a){
8:         return a + 2;
9:     }
10:    public static void main(String args[]){
11:        A a = new B();
12:        System.out.println(a.getNumber(0));
13:    }
14:}

a.compilation succeed and 1 is printed
b.compilation succeed and 2 is printed
c.,d.




 : b



١86.  (ΰ)

a.16/2^2
b.16>>2
c.16>>>2
d.16/2
e.16*4




 : c,e(ƴϾ! b,c.



87.which two are reserved word in java?

a.run 
b.import 
c.default 
d.implement




 : b,c - d.implement(s ־)



١١١88.
public class Syntest{
    public static void main(String []args){
        final StringBuffer s1=new StringBuffer();
        final StringBuffer s2=new StringBuffer(); 

        new Thread(){
            public void run(){
                synchronized(s1){
                   s1.append("a");
                   synchronized("b"){
                       System.out.println(s1);
                       System.out.println(s2);
                   }
                }
           }
        }.start();//error ƴ
 
        new Thread(){
            public void run(){
                synchronized(s2){
                   s2.append("c");
                   synchronized(s1){
                       s1.append("d");
                       System.out.println(s2);
                       System.out.println(s1);
                   }
                }
            }
        }.start();
   }
}
 
 

a.print ABBCAD
b.print CDDACB
c.print ADCBADBC
d.The output is a not-deterministic point because of a possible deadlock condition
e.The output is dependent on the threading model of the system the program is running on.




:   .    ã µ e ´    ϳ  𸣰...
 ѹ ãƺ..^.^ 
(a

 

c

ad )
       ->  d,e  ( krood Ե Q&A ׷ٰ )
 

١١89.
int i=1;
int j=i++;                     
if((i>++j)&(i++==j))
    i+=j;
 i?




 : i=3
Կ  ߿ 켱  Դϴ.
2° ٿ ++ i 2 . 
׸ ǹ , i++ ѹ . ׷ i 3̵. 
 false̹Ƿ i+=j;  ȵǰ.
keypoint: if(A&B)   ->      A, B Ѵ  
          if(A&&B)  ->     A false B ʴ´. by @@


90.
int i=1;
int j=i++;
if((i>++j)&&(i++==j))
    i+=j;
 i ? (!!!!!!)




 : i=2(켱 Ű澲 Ǯ)



١١١91. 
abstract class A{
abstract methodA();
abstract methodB(){
....
....
}
}

compile  Ƿ( Ǿ) ?

a. methodA  abstract  
b. methodB  abstract  
c. methodB {...} ְ ; ü
d. class  interface ġ methodB Ѵ.
e. class abstract ش.




 :  b,c,d



١١92. 
public class MethodOver{
    private int x,y;
    private float z;
    public void setVar(int a, int b, float c){
        x=a;
        y=b;
        z=c;
    }
} 
 
which two overload the setVar method?(choose two)
 
a. void setVar(int a, int b, float c){
        x=a;
        y=b;
        z=c;
    }
b. public void setVar(int a, float c, int b){
        setVar(a,b,c);
    }
c. public void setVar(int a, float c, int b){
        this(a,b,c);
    }
d. public void setVar(int a, float b){
        x=a;
        y=b;
    }
e. public void setVar(int ax, int by, float cz){
        x=ax;
        y=by;
        z=cz;
    }




 : b,d



١١93. 
public class x implements Runnable{
    public static void main(String args []){
// insert code here
    }

    public void run(){
        int x=0, y=0;
        for(;;){ 
           X++;
           Y++;
           System.out.println(x+","+y);
        }
    }
}
 
a. X x = new x();
    x.run();
b. X x = new x();
    new Thread(x).run();
c. X x = new x();
    new Thread(x).start();
d. Thread t = new Thread(X).run();
e. Thread t = new Thread(X).start();




 : c




94. 
public class x implements Runnable{
    private int x;
    private int y;
 
    public static void main(String args[] ){
        x that = new x();
        (new Thread(that)).start();
        (new Thread(that)).start();
    }
 
    public synchronized void run(){
        for(;;){        
           x++;
           y++;
           System.out.Println("x=" + x + ", y=" +y);
        }
    }
}
 
?

a. An error at line 11
b. An error at line 7, 8
c. The program prints pairs of values for x and y that might not always be the same on the same line (for example "x=2, y=1")
d. The program prints pairs of values for x and y that are always the same on the same line (for example "x=1, y=1") in addition, each value appears twice (for example "x=1, y=1" followed by "x=1, y=1")
e. The program prints pairs of values for x and y that are always the same on the same line (for example "x=1, y=1") in addition, each value appears only once (for example "x=1, y=1", followed by "x=2, y=2")
 



 : e
         -> run() synchronized   ͼ,  c 



95. Which gets the name of the parent directory of file "file.txt"?

a. String name = File.getParentName("file.txt");
b. String name = (new File ("file.txt").getParent());
c. String name = (new File ("file.txt").getParentName());
d. String name = (new File ("file.txt").getParentFile());
e. Directory dir = (new File ("file.txt").getParentDir());
f. String name = dir.getName();
 



 : b



96. What writes the text "" to the end of the file "file.txt"?
a. OutputStream out = new FileOutputStream("file.txt");
    out.writeBytes("");
b. OutputStream os = new FileOutputStream("file.txt", true);
    DataOutputStream out = new DateOutputStream(os);
    out.writeBytes("");
c. OutputStream os = new FileOutputStream("file.txt");
    DateOutputStream out = new DataOutputStream(os);
    out.writeBytes("");
d. OutputStream os = new OutputStream("file.txt", true);
    DateOutputStream out = new DataOutputStream(os);
    out.writeBytes("");




 : b



١١97. The file "file.txt" exists on the file System and contains ASCII text,
Given;

try{
     File f = new File ("file.txt");
     OutputStream out = new FileOutputStream("file.txt");
}
     catch(IOException e)  {}

Result?

a. The code not Compile
b. The code run and no change is made to the file
c. The code runs and sets the length of the file to 0.
d. An exception is thrown because the file from the file system.




 : c



98. 
public class x {
    public object m(){
        Object o=new Float(2.14);
        Object [] oa=new Object[1];
        oa[0]=o;
        o=null;
        return o;
    }
}
  
When is the Float object creation in line 3 eligible for garbage collection ?

a. just after line 5
b. just after line 6
c. just after line 7 (that is , as the method returns)
d. never




 : d



١١١99.
1: abstract class AbstractIt{
2.     abstract float getFloat();
3.}
4. public class AbstractTest extends AbstractIt{
5.     private float f1 = 1.0f;
6.     private float getFloat() { return f1;}
7.}

what result?
 
a. compile success
b. An error at line 6
c. An error at line 4
d. An error at line 2




 : b - ڰ  ͸ ü .  private  public/protected/(none modifier) .



١١100. 
class EnclosingOne {
    public class InsideOne {}
}
public class InnerTest {
    public static void main(String args[]) {
        EnclosingOne eo = new EnclosingOne();
    // INSERT CODE HERE
    }
}
 
a. InsideOne ei =eo.new InsideOne(); 
b. eo.InsideOne ei =eo.new InsideOne();
c. InsideOne ei = EnclosingOne.new InsideOne();
d. EnclosingOne.InsideOne ei = eo.new InsideOne();




 : d



١١101. Which statement is true
a. An anonymous inner class may be declared as final
b. An anonymous inner class can be declared as private
c. An anonymous inner class can implement multiple interface
d. An anonymous inner class can access final variable in any enclosing scope
e. Construction of an instance of a static inner class requires an instance of the enclosing outer class




 : d



١١102. 
1: public class Foo implements Runnable {
2:     public void run(Thread t) {
3:     System.out.println("Running.");
4:    }
5:     public static void main(String args[]) {
6:         new Thread (new Foo()).start();
7:    }
8:}

What is the result

a. An exception is thrown
b. The program exits without printing anything
c. An error at line 1 cause compilation to fail
d. An error at line 2 cause compilation to fail
e. "Running." is printed and the program exits
 



 : c 
       -> public void run(); ̶ ޼ҵ尡  Դϴ. 
          public void run(Thread t) Ǵٸ ޼ҵ ó˴ϴ. by rarame

 

١١103. Which is a method of the MouseMotionListener interface

a. public void mouseMoved (MouseEvent)
b. public boolean mouseMoved(MouseEvent)
c. public void mouseMoved (MouseMotionEvent)
d. public boolean mouseMoved(MouseMotionEvent)
e. public boolean mouseMoved(MouseMotionEvent)




 : a
         -> mouseMoved  mouseDragged   



104. 
1: import java.awt.*;
2:
3: public class X extends Frame {
4:     public static void main (String args[]) {
5:         X x = new X();
6:         x.pack();
7:         x.setVisible(true);
8:    }
9:
10:     public X() {
11:         setLayout( new GridLayout(2,2));
12:
13:         panel p1 = new panel();
14:         add(p1);
15:         Button b1 = new Button("One");
16:         p1.add(b1);
17:
18:         panel p2 = new panel();
19:         add(p2);
20:         Button b2 = new Button("Two");
21:         p2.add(b2);
22:
23:         Button b3 = new Button ("Three");
24:         add.(b3);
25:
26:         Button b4 = new Button("Four");
27:         add(b4);
28:    }
29:}

Which two statements are true ( 2 )

a. All the buttons change height if the Frame height is resized
b. All the buttons change width if the Frame width is resized
c. The size of the button Labeled "One" is constant even if the Frame resized
d. Both Width and height of the button Labeled "Three" might change if the Frame is resized




 : c,d



١١105. Given an ActionEvent which method allows you to identify the affected component

a. getClass 
b. getTarget 
c. getSource
d. getComponent 
e. getTargetComponent




 : c
         



١١106. Which method is an appropriate way to determine the cosine of 42 degrees

a. double d = Math.cos(42);
b. double d = Math.cosine(42);
c. double d = Math.cos(Math.Radians(42));
d. double d = Math.cos(Math.toDegrees(42));
e. double d = Math.cosine(Math.toRadians(42));

 

 
 : c


 
١١107. Which statement is true for the class java.util.HashSet

a. The elements in the collection are ordered
b. The collection is guaranteed to be immutable
c. The elements in the collection are guaranteed to be unique
d. The elements in the collection are accessed using a unique key
e. The elements in the collection are guaranteed to be synchronize
 
 


 : c 
<-  
Set հ ̽Դϴ. (տ ߺ Ҹ  ʴ´ٴ  ƽ^^) 
java.util.HashMap ٲٸ  d .. 
Map key ̿Ͽ Ÿ ϰԵ..(key ߺ ʽϴ.) by @@

 
 
108. You need to store elements in a collection that guaranteed that no duplicates are
stored and all elements can be accessed in natural order which interface provides that capability

a. java.util.Map 
b. java.util.Set 
c. java.util.List
d. java.util.SortedSet 
e. java.util.SortedMap 
f. java.util.collection

 

 
 : d


 
١١110. public class Outer Class {
    private double d1 = 1.0;
    //insert code here
}

You need to insert an inner class declation at line 3 which two inner class declation are valid?

a. static class InnerOne {
        public double method() { return d1;}
    }
b. static class InnerOne {
        static double method() { return d1;}
    }
c. private class InnerOne {
        public double method() { return d1;}
    }
d. protected class InnerOne {
        public abstract double method() { return d1;}
    }
e. public abstract class InnerOne {
        public abstract double method();
    }




 : c,e (a,b static̶ d1 ,d abstractϰ ڿ ();־,߻޼ҵ带 ϸ Լ ߻Ŭ Ǿ)

 

111. Which can be used to decode char s for input?

a. java.io.InputStream
b. java.io.EncodeReader
c. java.io.InputStreamReader
d. java.io.InputStreamWriter
e. java.io.BufferedInputStream
 



 : c



١١112.You want SubClass in any package to have access to method of a SuperClass.Which most restric access modifier that will accomplish this objective?

a.public 
b.private 
c.protected 
d.transient 
e.NoAccessModifer




 : c (same package  ƹ͵  ʿ)



113. 
byte a = 127 ;
byte b = 125 ;
byte c = a+ b;


 c?




 :  Ͽ        : a+b int ȯ c int ϰų a+b type castingؾ
           -> byte c = (byte)a+b  ص Ͽ 
           -> byte c = (byte)(a+b)   쿡 c = -4

     
 
114. 8 ߺ 

 

١١115. 
int index = 1;
int[] foo = new int[3];
int bar = foo[index];
int baz = bar[index];

what result?

a. baz has a value of 0
b. baz has a value of 1
c. baz has a value of 2
d. An Exception thrown
e. The code will not compile




 : e



116.Which three are valid declare of a float(Choose three.?

a. float foo = -1;
b. float foo = 1.0;
c. float foo = 42e1;
d. float foo = 2.02f;
e. float foo = 3.03d;
f. float foo = 0x0123;




 : a,d,f



١١117.
public class Test{
    public static void add3(Integer i){
        int val = i.intValue();
        val += 3;
        i = new Integer(val);
    }

    public static void main(String[] args){
        Integer i = new Integer(0);
        add3(i);
        System.out.println(i.intValue());
    }
}

What result?

a. compile fail
b. The program print "0"
c. The program print "3"
e. Compile success but Exception thrown at line 3




 : b



١118. which two statements are true (two)

a. An inner class may be declared as static
b. An annonymous inner class can be declared as public
c. An annonymous inner class can be declared as private
d. An annonymous inner class can extend an abstract class
e. An annonymous inner class can be declared as protected
 


 
 : a,d
 
 

١١119. Which statement is true

a. If only one thread is blocked in the wait method of an object and another thread
execute the notify method on that same object, then the first thread immediately
resumes execution.
 
b. If a thread is blocked in the wait method of an object, and another thread executes
the notify method on the same object, it is still possible that the first thread might
never resume execution.
 
c. If a thread is blocked in the wait method of an object, and another thread executes
the notify method on the same object then the first thread definitely resumes execution
as a direct and sole consequence of the notify call.
 
d. If two thread are blocked in the wait method of an object, and another thread
executes the notify method on the same object then the thread that executed the wait
call first definitely resumes execution as a direct and sole consequence of the notify call.

 
 

 : b



١١120. You are assigned the task of building a panel containing a TextArea
at the top a Label directly below it and a Button directly below the Label
If the Three components are added directly to the panel, which layout manager
can the panel use to ensure that the TextArea absorbs all of the free virtical space,
when the panel is resized.

a GridLayout 
b. CardLayout 
c. FlowLayout
d. BorderLayout 
e. GridBagLayout




 : e



121. 107 ߺ 



١١122.
class X{
    public static void main(String args[]){
        String a = new String("true");
        Boolean b = new Boolean(true);
        if(a.equals(b))
            System.out.println("true");
    }
}




 :  ǰ ƹ͵ Ʈ  ʴ´.



١١123. We have the following organization of classes.
    class Parent{};
    class DerivedOne extends Parent{};
    class DerivedTwo extends Parent{};

Which of the following statements is correct for the following expression.
    Parent p=new Parent();
    DerivedOne d1=new DeriveOne();
    d1=(DerivedOne)p;

a. illegal at compile.
b. Legal at compile time, but fails at runtime,
c. Legal at compile and runtime
d. illegal at compile, but legal runtime.




 : b



١١124. which statements about listeners are true?
a. At most one listener can be added to any single Component
b. If multiple listeners are added to a single Component, the order of invocation of the listener is not specified
c. The return value from a listener is used to control the invocation of other listeners
d. In the java Package, listener methods generally take an argument which is an instance of the some subclass of java.awt.AWTEvent class



 : b,d



١١125. Given the following declarations,
Integer s = new Integer(9);
Integer t = new Integer(9);
Long u = new Long(9);
 
Which tests would return true?

a. (s.equals(t));
b. (s.equals(new Integer(9));
c. (s.equals(9));
d. (s == t);
e. (s == u);




 : a,b(c, e  )



126. Which test would return true? ( multi )
Float s = new Float(0.9f);
Float t = new Float(0.9f);
Double u= new Double(0.9);

a. (s.equals(t))
b. (s.equals(u))
c. (s.equals(new Float(0.9f))
d. (s==t)
e. (s==u)




 : a,c



127. The following is the entire contents of a file called Test.java .

1: public class Test {
2:     static int x;
3:
4:     public static void main(String args[]){
5:         x = 8;
6:    }
7:}

α׷ compile  ٸ ?

a. The code compiles successfully.
b. A compiler error occurs at line 1.
c. A compiler error occurs at line 2.
d. A compiler error occurs at line 4.
e. A compiler error occurs at line 5.




 : a



١١128. which statements about the garbage collection mechanism are true?
a. Garbage collection requires additional program code in cases where multiple Threads are running.
b. The programmer can indicate that a reference through a local variable in no longer of interest.
c. The programmer has a mechanism that explicitly and immediately frees that memory used by java object.
d. The garbage collection mechanism release memory at predictable times.
e. the garbage collection system never reclaims memory from objects which are still accessible
to running user thread.




 : b,e



129. Which modifier should be applied to a method for the lock of the object this to be obtained
priority executing anyof the method body?

a. abstract
b. final
c. protected
d. static
e. synchronized




 : e  ü  ÷׸  ְ װ Ϸ  Ű带 Ѵ.

 

 

١١130. The following of preliminary analysis work describes a class that will be used frequently in many unrelated parts of a project 
"The Polygon object is a Drawable, A Polygon has vertex information stored in a vector, has a color, and a "fill" flag which is true or not"
which item types should be used when defining member variables of the Polygon class,
so it must closely corresponds to this analysis?

(  member data   Ǵ data type?)

a. boolean
b. Color
c. Vector
d. Object
e. Polygon
f. Drawable




 : a,b,c



١١131. what might cause the current thread to stop executing?

a. A thread of higher priority becomes ready(runnable.
b. when a thread is constructing a new thread
c. when The thread executes a wait() call
d. when The thread executes a waitForID(0 call on a MediaTracker)




 : a,c,d



١١132. 
public class Example{
    int x, z;
    float y;

    public Example(int a, int b){
        //do a lot of things
        x = a;
        z = b;
    }

    public Example(int a, int b, float c){
        //do everything that the two-argument
        //version do constructor does
        //including assign
        y = c;
    }
} 

most concise way to code at comment parts in three argumet-constructor?(ְ)




 :  this(a, b);   
       ݷ 
 
 
 
١١133. Choose right answer.

public class Example{
    public static void main(String args[]){
outer:
    for(int i=1; i<3; i++){
inner:
        for(int j=1; j<3; j++) 
            if(j==2)
                continue outer;
        System.out.println("Value are " + i + " " + j);
    }
}
  
a. Value are 1 1
b. Value are 1 2
c. Value are 1 3
d. Value are 2 1
e. Value are 2 2
f. Value are 2 3
 



 : a,d(continue϶  Ͽ  ,break϶ ű⼭ )



١١134. Given the following code what is the effect of a being 5
public class Test {
    public void add(int a. {
loop: for (int i = 1; i < 3; i++) {
            for (int j = 1; j < 3; j++) {
                if (a == 5) 
                    break loop;
            }
            System.out.println(i * j);
        }
    } 
}

a. Generate a runtime error
b. Throw an ArrayIndexOutOfBoundsException
c. Print the values: 1, 2, 2, 4
d. Produces no output




 : d



١١135.Which are keywords in Java?

a. sizeof 
b. goto 
c. NULL 
d. this 
e. BOOLEAN




 : b,d

 

١١136. You are writing a program. and particular method cannot be overriden in any way. but the class is going to subcalss. What modifier you should write before method?(ְ)




 : final



137. Given the following code

public class Test 

 
Which of the following can be used to define a constructor for this class

a. public void Test() 
b. public Test() 
c. public static Test() 
d. public static void Test() 


 

 : b  - Ŭ ̸  ̸  Լ. 
      ڸ   Ϸ ƱԸƮ  Ʈ ڸ .
      Ʈ  Ư¡ -  Ŭ ̸ ϴ,   Ÿ  ʴ´.

 

138. Which of the following are acceptable to the Java compiler

a. if (2 == 3) System.out.println("Hi");
b. if (2 = 3) System.out.println("Hi");
c. if (true) System.out.println("Hi");
d. if (2 != 3) System.out.println("Hi");
e. if (aString.equals("hello")) System.out.println("Hi");




 : a,c,d,e



١١139. Which of the following is a legal return type of a method overloading the following method

public void add(int a. 

a. void
b. int
c. Can be anything




 : c
       overloading:  Ŭ  Լ ̸ , Լ ƱԸƮ(ƱԸƮ , ƱԸƮ Ÿ) ٸ .



١١140. Which of the following statements is correct for a method which is overriding the following method

public void add(int a. 

a. the overriding method must return void
b. the overriding method must return int
c. the overriding method can return whatever it likes




 : a
       overriding: ñ״(Լ ̸, ڼ, Ÿ) ϰ  ؾ 



١١141. There in a constructor, can you place a call to a constructor defined in the super class?

a. Anywhere
b. The first statement in the constructor
c. The last statement in the constructor
d. You can't call super in a constructor




 : b



١١142. Which variables can an inner class access from the class which encapsulates it?
 
a. All static variables
b. All final variables
c. All instance variables
d. Only final instance variables
e. Only final static variables

 


 : a,b,c



١١143. In the following code, which is the earliest statement, where the object originally held in e, may be garbage collected

public class Test {
    public static void main (String args []) {
        Employee e = new Employee("Bob", 48);
        e.calculatePay();
        System.out.println(e.printDetails());
        e = null;
        e = new Employee("Denise", 36);
        e.calculatePay();
        System.out.println(e.printDetails());
    }
}

a. Line 10
b. Line 11
c. Line 7
d. Line 8
e. Never




 : c (ѹ  ϸ ׶  ߵ)

 

١١144. Which methods may cause a thread to stop executing?

a. sleep();
b. stop();
c. yield();
d. wait();
e. notify();
f. notifyAll()
g. synchronized()




 : a,b,c,d



١١145. Write code to create a text field able to display 10 characters (assuming a fixed size font) displaying the initial string "hello"




 : new TextField("hello",10);



١١146. Which of the following methods are defined on the Graphics class

a. drawLine(int, int, int, int)
b. drawImage(Image, int, int, ImageObserver)
c. drawString(String, int, int)
d. add(Component);
e. setVisible(boolean);
f. setLayout(Object);




 : a,b,c



١١147. Which of the following layout managers honours the preferred size of a component

a. CardLayout
b. FlowLayout
c. BorderLayout
d. GridLayout




 : b
      FlowLayout : ι þ   ( Ʈ ũ )
      BorderLayout :  ڸ ҵ ʿ ũ⸸ŭ ڸ ϰ,߾ӿ ִ Ҵ 
      GridLayout : Ľ    ° ġ   ( Ʈ ũ )
      CardLayout :   ī带   ʿ 쿡 ϴ  ī带 ȭ鿡 ִ 
      GridBagLayout : Ʈ ġ ũ⸦ Ӱ   ִ ̾ƿ Ŵ

 

 

١١148. What is the effect of issuing a wait() method on an object

a. If a notify() method has already been sent to that object then it has no effect
b. The object issuing the call to wait() will halt until another object sends a notify() or notifyAll() method
c. An exception will be raised
d. The object issuing the call to wait() will be automatically synchronized with any other objects using the receiving object.




 : b



١١149.   native   ´  ?

a. public void native method()
b. public native void method();
c. public native method();
d. public native void method()




 : b

 

١١150.  true  ?

a. int a[][] = new int[10,10];
b. int a[10][10] = new int[][];
c. int a[][] = new int[10][10];
d. int []a[] = new int[10][10];
e. int [][]a = new int[10][10];




 : c,d,e



١١151.(ְ)

String s="Hello";
s=s.toLowerCase() + " there";
System.out.println(s + " my friend");

  ?




 : hello there my friend



152. What is the range of values that can be assigned to a variable of type char?

a. It depends on the underlying hardware.
b. 0 through 2^16-1
c. 0 through 2^32-1
d. -2^15 through 2^15-1
e. -2^31 through 2^31-1




 : b



ڡڡڡ153. You try to get "Test2". which value of variable x is correct?

if(x>4)
    System.out.println("Test1");
else if(x>9)
    System.out.println("Test2");
else
    System.out.println("Test3");
 
a. x>4
b. x>9
c. 0<=x<=4
d. less then 0
e. none




 : e



١١154. What results from attempting to compile and run the following code?

import java.awt.*;
import java.awt.event.*;
 
public class Test {
    public static void main( String args[] ) {
        String s = "Happy";
        Frame f = new Frame();
        Button btn = new Button();
        btn.addActionListener(
            new ActionListener(){
                public void actionPerformed( ActionEvent e ){
                    System.out.println( "Message is " + s );
                }
            }
        );

        f.add( btn );
        f.setVisible( true );
}

a. both compile and runtime is successful but nothing is displayed
b. both compile and runtime is successful and if you click button display Message is Happy
c. compile is successful but runtime is fail
d. compile is failed because String s cannot be used .........
e. compile is failed because class Test ......... not implements ActionListener




 : d - s final̾ Ѵ.   Ŭ    final   ִ.



١١155. Given the following declarations:

class C {
    private int val;
    public C (int v) {
        val = v;
    } 
}

C a = new C (10);
C b = new C (10);
C c = b;
int x = 10;
long y = 10L;

Which logical expressions are both valid and have the value true ? ( multi )

a. (a == x)
b. (a == b)
c. (b == c)
d. (x == y)
e. (y == 10.0)
f. (x == 10.0)




 : c,d,e,f(a C int == 񱳰 ȵǰ b false,equals ؾ߸Ѵ.)



156. true  ? ( multi )

String s = "Hello"


a. char c =s[3]
b. int i = s.length ( )
c. s >>= 2
d. String loverS = s.trim( )
e. s = s + 3




 : b,d,e (e s=s+3 "3",'3'  )
         ->   String s = Hello ̿  



157. 
class C {
    private long val; 
    public C(long v) { val = v;}
}
 
C x=new C(10L);
C y=new C(10L);
C z=y;
long a = 10L;
int b = 10;

a. (x==y)
b. (z==y)
c. (a==b)
d. (a==10.0)




 : b,c,d



١١158. print  s1, s2?

import java.util.*;

class A {
    public static void main(String args[]) {
        Stack s1 = new Stack();
        Stack s2 = new Stack();
        A a = new A();
        a. method(s1, s2);
        System.out.println(s1);
        System.out.println(s2);
    }

    void method(Stack s1, Stack s2) {
        s2.push(new Integer(100));
        s2.push(new Integer(200));
        s1=s2;
    }
}




 : [ ]
[100, 200]



159. Given the following code. Which lines would be output when the program is run?

class Parent{
    String primary;
    String second;

    public Parent(String p,String c){
        primary=p;
        second=c;
    }
    public String toString(){ return primary;}
}

class Child extends Parent{
    public Child(String p,String c){ super(p,c);}
    public String toString(){ return primary+"a.k.a"+second;}
}

public class Example{
    public staitc void main(String args[]){
        Parent p=new Parent("first","second");
        Parent p1=new Child("first","second");
        System.out.println(p);
        System.out.println(p1);
    }
}

Write the output .




 : first firsta.k.asecond



١١160. Which of the following are appropriate to declare an array of 50 String Objects?

a. String a[50];
b. Object ob[50];
c. String s[];
d. String []s;




 : c,d



١١161. What should you use to position a Button, within an application Frame, so that the height of the Button is affected by the Frame size, but the width is not?

a. the North or South
b. the West or East
c. Center
d. FlowLayout
e. GridLayout




 : b



162. Which are valid identifiers ?

a. %fred
b. *fred
c. thisfres
d. 2fred
e. fred




 : c,e  - ҹ, (, ùڸ ȵ), _(underbar), $  , Ưھȵ
         ex) _import(o), $fred(o), _$12$_(o), C-Class (x) 



١١163. Which component cannot be added to a container?

a. Component
b. MenuComponent
c. Container
d. Applet
e. Label




 : b



164. What is result? (ְ)
public class Test{ 

    public static void main(String args[])
    {
        String s="base";

        s.concat("home");
        s.replace('a','e');
        s+="ball";

        System.out.println(s);
    }
}




 : baseball



165.
public class Test{ 
    public static void main(String args[])
    {
        String s="true";
        Boolean b= new Boolean(true);

        if(s.equals(b)) 
           System.out.println("true");
    }
}

What is result? ()




 : compile and runtime is successful but nothing is displayed


--------------------------------------------------------------------------------
 





