问题:单选题public class Test { private static int[] x; public static void main(String[] args) { System.out.println(x[0]); } } What is the result?()A0BnullCCompilation fails.DA NullPointerException is thrown at runtime.EAn ArrayIndexOutOfBoundsException is thrown at runtime.
查看答案
问题:单选题public class Threads5 { public static void main (String[] args) { new Thread(new Runnable() { public void run() { System.out.print(”bar”); } }).start(); } } What is the result?()ACompilation fails.BAn exception is thrown at runtime.CThe code executes normally and prints “bar”.DThe code executes normally, but nothing prints.
问题:填空题5. String foo = “base”; 6. foo.substring(0,3); 7. foo.concat(“ket”) 8. Type the value of foo at line 8.()
问题:单选题class super { public int getLength() {return 4;} } public class Sub extends Super { public long getLength() {return 5;} public static void main (String[]args) { super sooper = new Super (); Sub sub = new Sub(); System.out.printIn( sooper.getLength()+ “,” + sub.getLength() }; } What is the output?()A4, 4B4, 5C5, 4D5, 5EThe code will not compile.
问题:单选题A class design requires that a member variable cannot be accessible directly outside the class. Which modifier should be used to obtain the access control?()ApublicBno modifierCprotectedDprivate
问题:多选题Which are syntactically valid statement at// point x?() class Person { private int a; public int change(int m){ return m; } } public class Teacher extends Person { public int b; public static void main(String arg[]){ Person p = new Person(); Teacher t = new Teacher(); int i; // point x } }Ai = m;Bi = b;Ci = p.a;Di = p.change(30);Ei = t.b.
问题:单选题An instance member()A is also called a static memberB is always a variableC is never a methodD belongs to a single instance, not to the class as a wholeE always represents an operation
问题:多选题Which two demonstrate encapsulation of data? ()AMember data have no access modifiers.BMember data can be modified directly.CThe access modifier for methods is protected.DThe access modifier to member data is private.EMethods provide for access and modification of data.
问题:单选题What will be written to the standard output when the following program is run?() public class Q8499 { public static void main(String args[]) { double d = -2.9; int i = (int) d; i *= (int) Math.ceil(d); i *= (int) Math.abs(d); System.out.println(i); } }A 12B 18C 8D 9E 27
问题:多选题Which two valid declarations of a char? ()AChar ch = “a”;BChar ch = ‘“‘ ‘;CChar ch = ‘cafe‘;DChar ch = “cafe”;EChar ch = ‘“ucafe‘;FChar ch = ‘“u10100‘;GChar ch = (char) true;
问题:单选题Which of the following range of short is correct?()A-27 -- 27-1B0 -- 216-1C-215 -- 215-1D-231 -- 231-1
问题:单选题1. class Pizza { 2. java.util.ArrayList toppings; 3. public final void addTopping(String topping) { 4. toppings.add(topping); 5. } 6. } 7. public class PepperoniPizza extends Pizza { 8. public void addTopping(String topping) { 9. System.out.println(”Cannot add Toppings”); 10. } 11. public static void main(String[] args) { 12. Pizza pizza = new PepperoniPizza(); 13. pizza.addTopping(”Mushrooms”); 14. } 15. } What is the result?()ACompilation fails.BCannot add ToppingsCThe code runs with no output.DA NullPointerException is thrown in Line 4.
问题:多选题AnInterface is an interface. AnAdapter0 is a non-abstract, non-final class with a zero argument constructor. AnAdapter1 is a non-abstract, non-final class without a zero argument constructor, but with a constructor that takes one int argument. Which two construct an anonymous inner class? ()AAnAdapter1 aa=new AnAdapter1(){}BAnAdapter0 aa=new AnAdapter0(){}CAnAdapter0 aa=new AnAdapter0(5){}DAnAdapter1 aa=new AnAdapter1(5){}EAnInterface a1=new AnInterface(5){}
问题:填空题Public class test ( Public static void stringReplace (String text) ( Text = text.replace („j„ , „i„); ) public static void bufferReplace (StringBuffer text) ( text = text.append (“C”) ) public static void main (String args ){ String textString = new String (“java”); StringBuffer text BufferString = new StringBuffer (“java”); stringReplace (textString); BufferReplace (textBuffer); System.out.printIn (textString + textBuffer); } ) What is the output?()
问题:单选题10. interface A { void x(); } 11. class B implements A { public void x() { } public voidy() { } } 12. class C extends B { public void x() {} } And: 20. java.util.List list = new java.util.ArrayList(); 21. list.add(new B()); 22. list.add(new C()); 23. for (A a:list) { 24. a.x(); 25. a.y();; 26. } What is the result?()AThe code runs with no output.BAn exception is thrown at runtime.CCompilation fails because of an error in line 20.DCompilation fails because of an error in line 21.ECompilation fails because of an error in line 23.FCompilation fails because of an error in line 25.
问题:单选题11. public enum Title { 12. MR(”Mr.”), MRS(”Mrs.”), MS(”Ms.”); 13. private final String title; 14. private Title(String t) { title = t; } 15. public String format(String last, String first) { 16. return title + “ “ + first + “ “ + last; 17. } 18. } 19. public static void main(String[] args) { 20. System.out.println(Title.MR.format(”Doe”, “John”)); 21. } What is the result?()AMr. John DoeBAn exception is thrown at runtime.CCompilation fails because of an error in line 12.DCompilation fails because of an error in line 15.ECompilation fails because of an error in line 20.
问题:单选题11. abstract class Vehicle { public int speed() { return 0; } } 12. class Car extends Vehicle { public int speed() { return 60; } } 13. class RaceCar extends Car { public int speed() { return 150; }} ...... 21. RaceCar racer = new RaceCar(); 22. Car car = new RaceCar(); 23. Vehicle vehicle = new RaceCar(); 24. System.out.println(racer.speed() + “, „ + car.speed() 25. + “, “+ vehicle.speed()); What is the result?()A0, 0,0B150, 60, 0CCompilation fails.D150, 150, 150EAn exception is thrown at runtime.
问题:多选题Which two valid declarations of a char?()AChar ch = “a”;BChar ch = ‘/’ ‘;CChar ch = ‘cafe’;DChar ch = “cafe”;EChar ch = ‘/ucafe’;FChar ch = ‘/u10100’;GChar ch = (char) true;
问题:多选题public class SyncTest{ public static void main(String args) { final StringBuffer s1= new StringBuffer(); final StringBuffer s2= new StringBuffer(); new Thread () { public void run() { synchronized(s1) { s2.append(“A”); synchronized(s2) { s2.append(“B”); System.out.print(s1); System.out.print(s2); } } } }.start(); new Thread() { public void run() { synchronized(s2) { s2.append(“C”); synchronized(s1) { s1.append(“D”); System.out.print(s2); System.out.print(s1); } } } }.start(); } } Which two statements are true? ()AThe program prints “ABBCAD”BThe program prints “CDDACB”CThe program prints “ADCBADBC”DThe output is a non-deterministic point because of a possible deadlock condition.EThe output is dependent on the threading model of the system the program is running on.
问题:多选题Which two CANNOT directly cause a thread to stop executing?()ACalling the yield method.BCalling the wait method on an object.CCalling the notify method on an object.DCalling the notifyAll method on an object.ECalling the start method on another Thread object.