1. class A {  2. public byte getNumber ()  {  3.   return 1;  4.   }  5. }  6.    7. class B extends A {  8. public short getNumber()  {  9.  return 2;  10. }  11.    12. public static void main (String args[]) {   13.    B  b = new B ();  14.      Syste

题目

1. class A {  2. public byte getNumber ()  {  3.   return 1;  4.   }  5. }  6.    7. class B extends A {  8. public short getNumber()  {  9.  return 2;  10. }  11.    12. public static void main (String args[]) {   13.    B  b = new B ();  14.      System.out.printIn(b.getNumber())     15.   }  16. }    What is the result?()  

  • A、 Compilation succeeds and 1 is printed.
  • B、 Compilation succeeds and 2 is printed.
  • C、 An error at line 8 causes compilation to fail.
  • D、 An error at line 14 causes compilation to fail.
  • E、 Compilation succeeds but an exception is thrown at line 14.

相似考题
更多“1. class A {&ens”相关问题
  • 第1题:

    下面程序输出的结果为( )。 #inClUde”iostream.h” Class A {public: A(){cout<<“CLASS A”<<endl;} ~A()<)}; class B:public A {public: B(){cout<<”CLASSB”<<endl;} ~B(){}}; void main() {A*p; p=new B; B *q; q=new B;}

    A.CLASS A CLASS B

    B.CLASS A CLASS B CLASS B

    C.CLASS A ClASS B

    D.CLASS A CLASS B CLASS A CLASS B CLASS B CLASS B


    正确答案:C
    解析: 本题考查类的继承、类的实例化和构造函数、析构函数的调用方式和何时调用。每实例化一个类就要调用其构造函数,结束运行该实例后调用析构函数。

  • 第2题:

    Alloftheclientcomputersinyourcompany’s&ens

    Alloftheclientcomputersinyourcompany’snetworkareWindows2000portablecomputers.AusernamedMariastoresSalesfilesinherMyDocumentsfolder.Sheusesthesefileswhenshetravels.

    Mariainformsyouthatwhenshetakesherportablecomputertotradeshows,shecanaccesssomeoftheSalesfilesbutnotallofthem.Whenherportablecomputerisconnectedtothenetworkattheoffice,shecanaccessallofthefiles.YouneedtoenableMariatoaccessallofthefilesinherMyDocumentsfolderwhensheisworkingremotely.

    Whatshouldyoudo?()


    参考答案:C

    TogiveMariaaccesstothefileswhensheisworkingremotely,thefolderneedstobeenabledforofflineaccessandmustbeconfiguredtomaketheentirecontentsofthefolderavailableoffline.

  • 第3题:

    1. public class Target {  2. private int i = 0;  3. public int addOne() {  4. return ++i;  5. }  6. }  And:  1. public class Client {  2. public static void main(String[] args) {  3. System.out.println(new Target().addOne());  4. }  5. }  Which change can you make to Target without affecting Client?() 

    • A、 Line 4 of class Target can be changed to return i++;
    • B、 Line 2 of class Target can be changed to private int i = 1;
    • C、 Line 3 of class Target can be changed to private int addOne() {
    • D、 Line 2 of class Target can be changed to private Integer i = 0;

    正确答案:D

  • 第4题:

    Class TestException  1. public class TestException extends Exception {  2. } Class a:  1. public class a {  2.  3. public String sayHello(String name) throws TestException {  4.  5. if(name == null) {  6. throw new TestException();  7. }  8.  9. return “Hello “+ name;  10. }  11.  12. }  A programmer wants to use this code in an application: 45. A a=new A();  46. System.out.println(a.sayHello(”John”));  Which two are true?()

    • A、 Class a will not compile.
    • B、 Line 46 can throw the unchecked exception TestException.
    • C、 Line 45 can throw the unchecked exception TestException.
    • D、 Line 46 will compile if the enclosing method throws a TestException.
    • E、 Line 46 will compile if enclosed in a try block, where TestException is caught.

    正确答案:D,E

  • 第5题:

    1. public class A {  2. void A() {  3. System.out.println(“Class A”);  4. }  5. public static void main(String[] args) {  6. new A();  7. }  8. }  What is the result?()  

    • A、 Class A
    • B、 Compilation fails.
    • C、 An exception is thrown at line 2.
    • D、 An exception is thrown at line 6.
    • E、 The code executes with no output.

    正确答案:E

  • 第6题:

    现自:  1.  interface Color {  }      2. interface Weight  {  }      3.  //insert code here    和以下足六个声明:  class Boat extends Color, extends Weight  {  }     class Boat extends Color and Weight  {  }      class Boat extends Color, Weight  {  }  class Boat implements Color,  implements Weight  {  }     class Boat implements Color and Weight  {  }      class Boat implements Color, Weight  {  }    分别插入到第3行,有多少行可以编译? () 

    • A、  0
    • B、  1
    • C、  2
    • D、  3

    正确答案:B

  • 第7题:

    单选题
    猪细小病毒的主要免疫原性蛋白是()
    A

    VP1

    B

    VP2

    C

    VP3

    D

    NS2

    E

    NS3


    正确答案: E
    解析: 暂无解析

  • 第8题:

    单选题
    Given classes defined in two different files:  1. package util;  2. public class BitUtils {  3. public static void process(byte[]) { /* more code here */ }  4. }  1. package app;  2. public class SomeApp {  3. public static void main(String[] args) {  4. byte[] bytes = new byte[256];  5. // insert code here  6. }  7. }  What is required at line 5 in class SomeApp to use the process method of BitUtils?()
    A

     process(bytes);

    B

     BitUtils.process(bytes);

    C

     util.BitUtils.process(bytes);

    D

     SomeApp cannot use methods in BitUtils.

    E

     import util.BitUtils.*; process(bytes);


    正确答案: E
    解析: 暂无解析

  • 第9题:

    单选题
    现有:  1. interface Animal {  2. void eat();  3. }  4.  5. // insert code here  6.  7. public class HouseCat extends Feline {  8. public void eat() { }  9. }   和五个声明:  abstract class Feline implements Animal { }  abstract class Feline implements Animal { void eat(); }  abstract class Feline implements Animal { public void eat(); }  abstract class Feline implements Animal { public void eat() { } }  abstract class Feline implements Animal { abstract public void eat(); }  分别插入到第5行,有几个可以通过编译?()
    A

    0

    B

    1

    C

    2

    D

    3


    正确答案: D
    解析: 暂无解析

  • 第10题:

    单选题
    1. public class a {  2. public void method1() {  3. try {  4. B b=new b();  5. b.method2();  6. // more code here  7. } catch (TestException te) {  8. throw new RuntimeException(te);  9. }  10. }  11. }  1. public class b {  2. public void method2() throws TestException {  3. // more code here  4. }  5. }  1. public class TestException extends Exception {  2. }  Given:  31. public void method() {  32. A a=new a();  33. a.method1();  34. }  Which is true if a TestException is thrown on line 3 of class b?()
    A

     Line 33 must be called within a try block.

    B

     The exception thrown by method1 in class a is not required to be caught.

    C

     The method declared on line 31 must be declared to throw a RuntimeException.

    D

     On line 5 of class a, the call to method2 of class b does not need to be placed in a try/catch block.


    正确答案: B
    解析: 暂无解析

  • 第11题:

    多选题
    1. public class A {  2. public void method1() {  3. B b=new B();  4. b.method2();  5. // more code here  6. }  7. }  1. public class B {  2. public void method2() {  3.C c=new C();  4. c.method3();  5. // more code here  6. }  7. }  1. public class C {  2. public void method3() {  3. // more code here  4. }  5. }  Given:  25. try {  26. A a=new A();  27. a.method1();  28. } catch (Exception e) {  29. System.out.print(”an error occurred”);  30. }  Which two are true if a NullPointerException is thrown on line 3 of class C?()
    A

    The application will crash.

    B

    The code on line 29 will be executed.

    C

    The code on line 5 of class A will execute.

    D

    The code on line 5 of class B will execute.

    E

    The exception will be propagated back to line 27.


    正确答案: D,C
    解析: 暂无解析

  • 第12题:

    单选题
    In a class of 160 seniors, the ratio of boys to girls is 3 to 5. In the junior class, the ratio of boys to girls is 3 to 2. When the two classes are combined, the ratio of boys to girls is 1 to 1. How many students are in the junior class?
    A

    400

    B

    360

    C

    200

    D

    180

    E

    160


    正确答案: C
    解析:
    因为这个班共有160人,男生和女生的比例为3:5,所以男生和女生的人数分别为(3/8) ×160 = 60人,(5/8) ×160 = 100人。假设另一班男生女生人数共有x人,那么男生女生的人数分别为(3/5)x,(2/5)x,又因为当两班的人数相加后,男生女生的比例相等,所以可得出60 + (3/5)x = 100 + (2/5)x,经计算,x = 200。

  • 第13题:

    YouareaExamSheetInc.consultantwhousesa&ens

    YouareaExamSheetInc.consultantwhousesaWindows2000Professionalportablecomputer.YourdomainuseraccountisamemberofthelocalAdministratorgroup.

    Fromyourportablecomputer,youmapadrivetoasharedfoldernamedConsultMerticsona

    computernamedServer1.YouconfigureConsultMerticstobeavailableoffline.Whenyoulogoftheportablecomputer,youreceivethefollowingerrormessage.

    Youneedtosuccessfullysynchronizetheofflinefiles.Whatshouldyoudo?()


    参考答案:D

  • 第14题:

    YouareaWindowsServer2008systemsadministrator&ens

    YouareaWindowsServer2008systemsadministratorresponsibleforprovidingaccesstoalargevolumeofvideofilestoregisteredusersofyourorganization??spublicWebsite.Allthevideofilesarelocated withintheD:\Public\Videosfolder.Contentproducersoftencreateandmodifythesevideos.Recently,usershavecomplainedthattheyareexperiencingpoorperformancewhenaccessingvideosduringbusytimes.Duringtheseimages,theWindowsMediaServicesserverthathoststhecontentisexperiencinghighCPUandnetworkbandwidthuse.Youwanttominimizetheadministrativetimeandeffortrequiredtoincreaseperformance.

    Whichofthefollowingactionsshouldyoutaketoresolvetheproblem?()


    参考答案:B

  • 第15题:

    1. public interface A {  2. public void doSomething(String thing);  3. }  1. public class AImpl implements A {  2. public void doSomething(String msg) { }  3. }  1. public class B {  2. public A doit() {  3. // more code here  4. }  5.  6. public String execute() { 7. // more code here  8. }  9. }  1. public class C extends B {  2. public AImpl doit() {  3. // more code here  4. }  5.  6. public Object execute() {  7. // more code here  8. }  9. }  Which statement is true about the classes and interfaces in the exhibit?() 

    • A、 Compilation will succeed for all classes and interfaces.
    • B、 Compilation of class C will fail because of an error in line 2.
    • C、 Compilation of class C will fail because of an error in line 6.
    • D、 Compilation of class AImpl will fail because of an error in line 2.

    正确答案:C

  • 第16题:

    1. public class a {  2. public void method1() {  3. try {  4. B b=new b();  5. b.method2();  6. // more code here  7. } catch (TestException te) {  8. throw new RuntimeException(te);  9. }  10. }  11. }  1. public class b {  2. public void method2() throws TestException {  3. // more code here  4. }  5. }  1. public class TestException extends Exception {  2. }  Given:  31. public void method() {  32. A a=new a();  33. a.method1();  34. }  Which is true if a TestException is thrown on line 3 of class b?()

    • A、 Line 33 must be called within a try block.
    • B、 The exception thrown by method1 in class a is not required to be caught.
    • C、 The method declared on line 31 must be declared to throw a RuntimeException.
    • D、 On line 5 of class a, the call to method2 of class b does not need to be placed in a try/catch block.

    正确答案:B

  • 第17题:

    1. public class Exception Test {  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 is necessary to make the code compile?()  

    • A、 No code is necessary.
    • B、 throws Exception
    • C、 catch ( Exception e )
    • D、 throws RuntimeException
    • E、 catch ( TestException e)

    正确答案:B

  • 第18题:

    1. public class enclosingone (  2. public class insideone{}  3. )  4. public class inertest(  5. public static void main (string[]args)(  6. enclosingone eo= new enclosingone ();  7. //insert code here  8. )  9. )    Which statement at line 7 constructs an instance of the inner class?()  

    • A、 InsideOnew ei= eo.new InsideOn();
    • B、 Eo.InsideOne ei = eo.new InsideOne();
    • C、 InsideOne ei = EnclosingOne.new InsideOne();
    • D、 EnclosingOne.InsideOne ei = eo.new InsideOne();

    正确答案:D

  • 第19题:

    单选题
    1. public class enclosingone (  2. public class insideone{}  3. )  4. public class inertest(  5. public static void main (string[]args)(  6. enclosingone eo= new enclosingone ();  7. //insert code here  8. )  9. )    Which statement at line 7 constructs an instance of the inner class?()
    A

     InsideOnew ei= eo.new InsideOn();

    B

     Eo.InsideOne ei = eo.new InsideOne();

    C

     InsideOne ei = EnclosingOne.new InsideOne();

    D

     EnclosingOne.InsideOne ei = eo.new InsideOne();


    正确答案: C
    解析: 暂无解析

  • 第20题:

    单选题
    Given classes defined in two different files:  1. package util;  2. public class BitUtils {  3. private static void process(byte[] b) { }  4. }  1. package app;  2. public class SomeApp {  3. public static void main(String[] args) {  4. byte[] bytes = new byte[256];  5. // insert code here  6. }  7. }  What is required at line 5 in class SomeApp to use the process method of BitUtils?()
    A

     process(bytes);

    B

     BitUtils.process(bytes);

    C

     app.BitUtils.process(bytes);

    D

     util.BitUtils.process(bytes);

    E

     import util.BitUtils. *; process(bytes);

    F

     SomeApp cannot use the process method in BitUtils.


    正确答案: F
    解析: 暂无解析

  • 第21题:

    单选题
    下列处方中常见的外文缩写,其含义是“立即”的是( )
    A

    Dos.

    B

    Sol.

    C

    St.

    D

    ss.

    E

    NS


    正确答案: B
    解析:

  • 第22题:

    多选题
    1. public class OuterClass {  2. private double d1 = 1.0;  3. // insert code here  4. }  Which two are valid if inserted at line 3?()
    A

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

    B

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

    C

    private class InnerOne { public double methoda() { return d1; } }

    D

    protected class InnerOne { static double methoda() { return d1; } }

    E

    public abstract class InnerOne { public abstract double methoda(); }


    正确答案: C,A
    解析: 暂无解析

  • 第23题:

    单选题
    1. public class A {  2. void A() {  3. System.out.println(“Class A”);  4. }  5. public static void main(String[] args) {  6. new A();  7. }  8. }  What is the result?()
    A

     Class A

    B

     Compilation fails.

    C

     An exception is thrown at line 2.

    D

     An exception is thrown at line 6.

    E

     The code executes with no output.


    正确答案: E
    解析: 暂无解析

  • 第24题:

    单选题
    Given a class Repetition:  1. package utils;  2.  3. public class Repetition {  4. public static String twice(String s) { return s + s; }  5. }  and given another class Demo:  1. // insert code here 2.  3. public class Demo {  4. public static void main(String[] args) {  5. System.out.println(twice(”pizza”));  6. }  7. }  Which code should be inserted at line 1 of Demo.java to compile and run Demo to print“pizzapizza”?()
    A

     import utils.*;

    B

     static import utils.*;

    C

     import utils.Repetition.*;

    D

     static import utils.Repetition. *;

    E

     import utils.Repetition.twice();

    F

     import static utils.Repetition.twice;

    G

     static import utils.Repetition.twice;


    正确答案: B
    解析: 暂无解析