考题
若有如下程序:public class Test {public static void main (String[] args) {int x=20;if (x>10) System.out.print(x-=5);if (x>5) System.out.print(x--);}}则程序运行后的输出结果是【 】。
考题
下列程序段运行的结果为 public class Test{ static void print(String s,int i){ System.out.println("String:"+s+",int:"+i); } static void print(int i,String s){ System.out.println("int:"+i+",String:"+s); } public static void main(String[]args){ print(99,"Int first"); } }A.String:String first,int:11B.int:11,String:Int firstC.String:String first,int99D.int:99,String:Int first
考题
publicclassBootchy{intbootch;Stringsnootch;publicBootchy(){this(”snootchy”);System.out.print(”first);}publicBootchy(Stringsnootch){this(420,snootchy”);System.out.print(”second);}publicBootchy(intbootch,Stringsnootch){this.bootch=bootch;this.snootch=snootch;System.out.print(”third);}publicstaticvoidmain(String[]args){Bootchyb=newBootchy();System.out.print(b.snootch++b.bootch);}}Whatistheresult?()A.snootchy420thirdsecondfirstB.snootchy420firstsecondthirdC.firstsecondthirdsnootchy420D.thirdsecondfirstsiiootchy420E.thirdfirstsecondsnootchy420F.firstsecondfirstthirdsnootchy420
考题
下列程序段运行的结果为 public class Test{ static void print(String s,int i){ System.out.println("String:"+s+",int:"+i); } static void print(int i, String s){ System.out.println("int:"+i+",String:"+s); } public static void main(String [] args){ print(99,"Int first"); } }A.String:Stringfirst,int:11B.int:11,String:Int firstC.String:String first,int:99D.int:99,String:int first
考题
3下列程序段运行的结果为( )。 public class Test{ static void print(String s,int i){ System.out.pdntlnC String: "+s+",int:"+i); } static void print(iht i,String s){ System.out.prinflnCint:"+i+",gtring:"+s); } public static void main(String[] args){ print(99,"Int first"); } }A.String:String first,int: 11B.int: 11,String:Int firstC.String:String first,int:99D. int:99,Stfing:Int first
考题
以下程序的运行结果为?class ValHold{public int i = 10;}public class ObParm{public static void main(String argv[]){ObParm o = new ObParm();o.amethod();}public void amethod(){int i = 99;ValHold v = new ValHold();v.i=30;another(v,i);System.out.print( v.i );}public void another(ValHold v, int i){i=0;v.i = 20;ValHold vh = new ValHold();v = vh;System.out.print(v.i);System.out.print(i);}}A.10030B. 20030C. 209930D. 10020
考题
以下程序调试结果为:class Base{Base(){int i = 100;System.out.print (i);}}public class Pri extends Base{static int i = 200;public static void main(String argv[]){Pri p = new Pri();System.out.print(i);}}
A.编译错误B.200C.100200D.100
考题
public class Pet{ private String name; public Pet(){ System.out.print(1); } public Pet(String name){ System.out.print(2); } } public class Dog extends Pet{ public Dog(String name){ System.out.print(3); } } 执行new Dog(“棕熊”);后程序输出是哪项?() A、 23B、 13C、 123D、 321
考题
public class Pet{ private String name; public Pet(String name){ this.name = name; } public void speak(){ System.out.print(name); } } public class Dog extends Pet{ public Dog(String name){ super(name); } public void speak(){ super.speak(); System.out.print(“ Dog ”); } } 执行代码 Pet pet = new Dog(“京巴”); pet.speak(); 后输出的内容是哪项?() A、 京巴B、 京巴 DogC、 nullD、 Dog京巴
考题
public class Base { public static final String FOO = “foo”; public static void main(String[] args) { Base b = new Base(); Sub s = new Sub(); System.out.print(Base.FOO); System.out.print(Sub.FOO); System.out.print(b.FOO); System.out.print(s.FOO); System.out.print(((Base)s).FOO); } } class Sub extends Base {public static final String FOO=bar;} What is the result?() A、 foofoofoofoofooB、 foobarfoobarbarC、 foobarfoofoofooD、 foobarfoobarfooE、 barbarbarbarbarF、 foofoofoobarbarG、 foofoofoobarfoo
考题
public class Employee{ private String name; public Employee(String name){ this.name = name; } public void display(){ System.out.print(name); } } public class Manager extends Employee{ private String department; public Manager(String name,String department){ super(name); this.department = department; } public void display(){ System.out.println(super.display()+”,”+department); } } 执行语句new Manager(“smith”,”SALES”)后程序的输出是哪项?() A、 smith,SALESB、 null,SALESC、 smith,nullD、 null,nullE、 编译错误
考题
public class Pet{ private String name; public Pet(){ System.out.print(1); } public Pet(String name){ System.out.print(2); } } public class Dog extends Pet{ public Dog(){ System.out.print(4); } public Dog(String name){ super(name); System.out.print(3); } } 执行new Dog(“棕熊”);后程序输出是哪项?() A、 33B、 13C、 23D、 123
考题
public class Employee{ private String name; public Employee(String name){ this.name = name; } public void display(){ System.out.print(name); } } public class Manager extends Employee{ private String department; public Manager(String name,String department){ super(name); this.department = department; } public void display(){ System.out.println( super.display()+”,”+department); } } 执行语句new Manager(“smith”,”SALES”)后程序的输出是哪项?() A、 smith,SALESB、 null,SALESC、 smith,nullD、 null,null
考题
public class Pet{ private String name; public Pet(){ System.out.print(1); } public Pet(String name){ System.out.print(2); } } public class Dog extends Pet{ public Dog(String name){ //这里隐藏了一句代码:super.pet(); System.out.print(3); } } 执行new Dog(“棕熊”);后程序输出是哪项?() A、 23B、 1 3C、 123D、 321
考题
Public class Holt extends Thread{ Private String sThreadName; Public static void main(String argv[]) { Holt h=new Holt(); h.go(); Holt(){}; Holt(String s){ sThreadName=s; Public String getThreadName() { return sThreadName;} } Public void go(){ Hot first=new Hot("first"); first.start(); Hot second=new Hot("second"); second.start(); } Public void start() { For(int i=0;i2;i++) { System.out.print(getThreadName()+i); Try{ Thread.sleep(100); }catch(Exception e){ System.out.print(e.getMessage()) ; } } } } 当编译运行上面代码时,将会出现() A、编译时错误B、输出first0,second0,first0,second1C、输出first0,first1,second10,second1D、运行时错误
考题
public class Pet{ private String name; public Pet(){ System.out.print(1); } public Pet(String name){ System.out.print(2); } } public class Dog extends Pet{ public Dog(){ System.out.print(4); } public Dog(String name){ //这里隐藏了一句代码:super.pet(); this(); System.out.print(3); } } 执行new Dog(“棕熊”);后程序输出是哪项?() A、 143B、 423C、 243D、 1134
考题
class ClassA { public int numberOfinstances; protected ClassA(int numberOfinstances) { this.numberOflnstances = numberOfinstances; } } public class ExtendedA extends ClassA { private ExtendedA(int numberOfinstances) { super(numberOflnstances); } public static void main(String[] args) { ExtendedA ext = new ExtendedA(420); System.out.print(ext.numberOflnstances); } } Which is true?() A、 420 is the output.B、 An exception is thrown at runtime.C、 All constructors must be declared public.D、 Constructors CANNOT use the private modifier.E、 Constructors CANNOT use the protected modifier.
考题
class Beverage { Beverage() { System.out.print("beverage "); } } class Beer extends Beverage { public static void main(String [] args) { Beer b = new Beer(14); } public int Beer(int x) { this(); System.out.print("beer1 "); } public Beer() { System.out.print("beer2 "); } } 结果是什么?() A、beer1 beverageB、beer2 beverageC、beverage beer1D、编译失败
考题
public class Pet{ private String name; public Pet(){ System.out.print(1); } public Pet(String name){ System.out.print(2); } } public class Dog extends Pet{ public Dog(){ System.out.print(4); } public Dog(String name){ this(); System.out.print(3); } } 执行new Dog(“棕熊”);后程序输出是哪项?() A、 143B、 423C、 243D、 1134
考题
public class TestApp{ public static void main(String[] args){ try{ int i = 0; int j = 1 / i; String myname=null; if(myname.length()2) System.out.print(“1”); }catch(NullPointerException e){ System.out.print(“2”); } catch(Exception e){ System.out.print(“3”); } } } 上述程序运行后的输出是哪项?()A、 3B、 2C、 231D、 32
考题
单选题public class Pet{ private String name; public Pet(){ System.out.print(1); } public Pet(String name){ System.out.print(2); } } public class Dog extends Pet{ public Dog(String name){ System.out.print(3); } } 执行new Dog(“棕熊”);后程序输出是哪项?()A
23B
13C
123D
321
考题
单选题public class Bootchy { int bootch; String snootch; public Bootchy() { this(”snootchy”); System.out.print(”first “); } public Bootchy(String snootch) { this(420, “snootchy”); System.out.print(”second “); } public Bootchy(int bootch, String snootch) { this.bootch = bootch; this.snootch = snootch; System.out.print(”third “); } public static void main(String[] args) { Bootchy b = new Bootchy(); System.out.print(b.snootch +“ “ + b.bootch); } } What is the result?()A
snootchy 420 third second firstB
snootchy 420 first second thirdC
first second third snootchy 420D
third second first siiootchy 420E
third first second snootchy 420F
first second first third snootchy 420
考题
单选题public class Pet{ private String name; public Pet(String name){ this.name = name; } public void speak(){ System.out.print(name); } } public class Dog extends Pet{ public Dog(String name){ super(name); } public void speak(){ super.speak(); System.out.print(“ Dog ”); } } 执行代码 Pet pet = new Dog(“京巴”); pet.speak(); 后输出的内容是哪项?()A
京巴B
京巴 DogC
nullD
Dog京巴
考题
单选题public class TestApp{ public static void main(String[] args){ try{ int i = 0; int j = 1 / i; String myname=null; if(myname.length()2) System.out.print(“1”); }catch(NullPointerException e){ System.out.print(“2”); } catch(Exception e){ System.out.print(“3”); } } } 上述程序运行后的输出是哪项?()A
3B
2C
231D
32
考题
单选题public class Pet{ private String name; public Pet(){ System.out.print(1); } public Pet(String name){ System.out.print(2); } } public class Dog extends Pet{ public Dog(String name){ //这里隐藏了一句代码:super.pet(); System.out.print(3); } } 执行new Dog(“棕熊”);后程序输出是哪项?()A
23B
1 3C
123D
321
考题
单选题class Beverage { Beverage() { System.out.print("beverage "); } } class Beer extends Beverage { public static void main(String [] args) { Beer b = new Beer(14); } public int Beer(int x) { this(); System.out.print("beer1 "); } public Beer() { System.out.print("beer2 "); } } 结果是什么?()A
beer1 beverageB
beer2 beverageC
beverage beer1D
编译失败
考题
单选题public class Base { public static final String FOO = “foo”; public static void main(String[] args) { Base b = new Base(); Sub s = new Sub(); System.out.print(Base.FOO); System.out.print(Sub.FOO); System.out.print(b.FOO); System.out.print(s.FOO); System.out.print(((Base)s).FOO); } } class Sub extends Base {public static final String FOO=bar;} What is the result?()A
foofoofoofoofooB
foobarfoobarbarC
foobarfoofoofooD
foobarfoobarfooE
barbarbarbarbarF
foofoofoobarbarG
foofoofoobarfoo