|
|
/** * * @author yaoyuan */12public class Certkiller5{13public static void main(String[] yahoo){14for(int x=1;x<yahoo.length;x++){15System.out.print(yahoo[x] + " ");16}17}18}19
/**
*and the command and line invocation java Certkiller5 a b c, What is the result?
*
*
*
*A a b
*Bb c
*Ca b c
*DCompilation fails
*EAn exception is thrown at runtime
*/
// Answer : B
/**
* 注意14行的,x的值
*
*/
/** * * @author yaoyuan */11public static void certkiller(String str){12int check = 4;13if(chect = str.length()){14System.out.print(str.charAt(check = 1) + "");15}else{16System.out.print(str.charAt(0) + "");17}18}and the invocation:13certkiller("four");14certkiller("tee");15certkiller("to");
/**
*What is the result?
*
*
*
*Ar,t,t
*Br,e,o
*CCompilation fails
*DAn exception is thrown at runtime
*/
// Answer : C
/** * * @author yaoyuan */11public class Certkiller{12public static void main(String[] args){13String myProp = /*insert code here*/14System.out.println(myProp);1516
/**
*and the command line:
*java -D rop.custom = gobstopperCertkiller
*Which two placed on line 13, will produce the output gobstopper?(choose two)
*
*
*ASystem.load("prop,custom");
*BSystem.getenv("prop.custom");
*CSystem.property("prop.custom");
*DSystem.getProperty("prop.custom");
*ESystem.getProperties().getProperty("prop.custom");
*/
// Answer : D E
/** * * @author yaoyuan */1package util;2public class BitUtils{3public static void process(byte []){/*more code here*/}4}1package app;2public class CertkillerApp{3public static void main(String[] args){4byte[] bytes = new byte[256];5//insert code here6}7}
/**
*What is required at line 5 in class CertkillerApp to use the process method of BitUtils?
*
*
*
*A Process(bytes);
*BBitUtils.process(bytes);
*CUtil.BitUtils.process(bytes);
*DCertkillerApp cannot use method in BitUtils
*EImport util.BitUtils.*; process(bytes);
*/
// Answer : C
/** * * @author yaoyuan */public class Item{private String desc;public String getDescription(){return desc;}public void setDescription(String d){desc = 1;}public static void modifyDesc(Item item, String desc){item = new Item();item.setDescription(desc);}public static void main(String[] args){Item it = new Item();it.setDescription("Gobstopper");Item it2 = new Item();it2.setDescription("Fizzylifting");modifyDesc(it, "Scrumdiddlyumptious");System.out.println(it.getDescription());System.out.println(it2.getDescription());}}
/**
*What is the out come of the code?
*
*
*ACompilation fails
*BGobstopper
*Fizzylifting
*CGobstopper
*Scrumdiddlyumptious
*DScrumdiddlyumptious
*Fizzylifting
*EScrumdiddlyumptious
*Scrumdiddlyumptious
*/
// Answer : B
/** * * @author yaoyuan */class CertKiller1{public CertKiller1(){System.out.print(1);}}class CertKiller2 extends CertKiller1{public CertKiller2(){System.out.print(2);}}class CertKiller3 extends CertKiller2{public CertKiller3(){System.out.print(3);}}public class Numbers{public static void main(String[] args){new CertKiller3();}}
/**
*What is the result when this code executed?
*
*
*A 1
*B3
*C123
*D321
*EThe code runs with no output
*/
// Answer : C
/** * * @author yaoyuan *//***Place the code fragments in position to complete the Displayable interface.*/interface Reloadable{public void reload();}class Edit{public void edit(){/* Edit Here*/}}interface Displayable [place here] [place here]{[place here]}}
/**
*Code Fragments
*
*extends public void display();Reloadable
*implementspublic void display();/"Display"/};Edit
*/
// Answer :
// interface Displayable extends Reloadable{
// public void display();
// }
/** * * @author yaoyuan */class CertKiller{public enum Direction{NORTH,SOUTH,EAST,WEST}public class Sprite{14//insert code here}}
/**
*Which code ,inserted at line 14, allows the Sprite class to compile?
*
*
*ADirection d = NORTH
*BCertKiller.Direction = NORTH
*CDirection = Direction.NORTH
*DCertKiller.Direction d = CertKiller Direction.NORTH
*/
// Answer : D
/** * * @author yaoyuan */10interface Foo{11int bar();12}1314public class Beta{1516class A implements Foo{17public int bar(){return 1;}18}1920public int fubar(Foo foo){return foo.bar();}2122public void testFoo(){2324class A implements Foo{25public int bar(){return 2;}26}2728System.out.println(fubar(new A();));29}3031public static void main(String[] argv){32new Beta.testFoo();33}34}
/**
*Which three statements are true?(choose three)
*
*
*ACompilation fails
*BThe code compiles and the output is 2
*CIf lines 16, 17 and 18 were removed, compilation would fail
*DIf lines 24,25 and 26 were removed, compilation would fail.
*EIf lines 16 ,17 and 18 were removed, the code would compiled and the output would be 2
*FIf lines 24, 25 and 26 were removed, the code would compiled and the output would be 1
*/
// Answer : B E F
/**
*
* @author yaoyuan
*/
/**
*Add methods to the Bate class to make it compile correctly
*/
class Alpha{public void bar(int...x){}public void bar(int x){}}public class Beta extends Alpha{[place here][place here][place here]}
/**
*Methods
*
*private void bar(int x){}public void bar(int x){}
*public int bar(String x){return 1;}public Alpha bar(int x){}
*public void bar(int x, int y){}public int bar(int x){return x}
*/
// Answer :
// public class Beta extends Alpha{
// public void bar(int x, int y){}
// public int bar(String x){return 1;}
// public void bar(int x){}
// }
//
//
|
|