单选题Which line contains a constructor in this class definition?()   public class Counter { // (1)   int current, step;   public Counter(int startValue, int stepValue) { // (2)   set(startValue);   setStepValue(stepValue);  }   public int get() { return current; } // (3)   public void set(int value) { current = value; } // (4)   public void setStepValue(int stepValue) { step = stepValue; } // (5)  }ACode marked with (1) is a constructorBCode marked with (2) is a constructorCCode marked with (3) is a constructorDCode marked with (4) is a constructorECode marked with (5) is a Constructor

单选题
Which line contains a constructor in this class definition?()   public class Counter { // (1)   int current, step;   public Counter(int startValue, int stepValue) { // (2)   set(startValue);   setStepValue(stepValue);  }   public int get() { return current; } // (3)   public void set(int value) { current = value; } // (4)   public void setStepValue(int stepValue) { step = stepValue; } // (5)  }
A

Code marked with (1) is a constructor

B

Code marked with (2) is a constructor

C

Code marked with (3) is a constructor

D

Code marked with (4) is a constructor

E

Code marked with (5) is a Constructor


参考解析

解析: 暂无解析

相关考题:

下列说法正确的有()A.class中的constructor不可省略B.constructor必须与class同名,但方法不能与class同名C.constructor在一个对象被new时执行D.一个class只能定义一个constructor

关于constructor,下列描述正确的是()。 A.class中的constructor不可省略B.constructor在一个对象被new时执行C.一个class只能定义一个constructorD.constructor必须与class同名,但方法不能与class同名

Click the Exhibit button. 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

Click the Exhibit button. Given:Which statement 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.

Click the Exhibit button. Given:Which two statements 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.

class A {  A() { }  }  class B extends A {  }  Which two statements are true?()A、 Class B’s constructor is public.B、 Class B’s constructor has no arguments.C、 Class B’s constructor includes a call to this().D、 Class B’s constructor includes a call to super().

Which three statements are true?()A、 The default constructor initializes method variables.B、 The default constructor has the same access as its class.C、 The default constructor invoked the no-arg constructor of the superclass.D、 If a class lacks a no-arg constructor, the compiler always creates a default constructor. E、 The compiler creates a default constructor only when there are no other constructors for the class.

Which two statements are true regarding the creation of a default constructor?()   A、 The default constructor initializes method variables.B、 The default constructor invokes the no-parameter constructor of the superclass.C、 The default constructor initializes the instance variables 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 when there are no other constructors for the class.

In which two cases does the compiler supply a default constructor for class A?()  A、 class A{}B、 class A { public A(){} }C、 class A { public A(int x){} }D、 class Z {} class A extends Z { void A(){} }

Which two statements are true regarding the creation of a default constructor?() A、 The default constructor initializes method variables.B、 The compiler always creates a default constructor for every class.C、 The default constructor invokes the no-parameter constructor of the superclass.D、 The default constructor initializes the instance variables declared in the class.E、 When a class has only constructors with parameters, the compiler does not create a default constructor.

10. class Line {  11. public static class Point { }  12. }  13.  14. class Triangle {  15. // insert code here  16. }  Which code, inserted at line 15, creates an instance of the Point class defined in Line?() A、 Point p = new Point();B、 Line.Point p = new Line.Point();C、 The Point class cannot be instatiated at line 15.D、 Line 1 = new Line() ; 1.Point p = new 1.Point();

public class X {   public static void main (String args) {   byte b = 127;   byte c = 126;   byte d = b + c;   }   }   Which statement is true?()  A、 Compilation succeeds and d takes the value 253.B、 Line 5 contains an error that prevents compilation.C、 Line 5 throws an exception indicating “Out of range”D、 Line 3 and 4 contain error that prevent compilation.E、 The compilation succeeds and d takes the value of 1.

Which of the following class networks contains 65,534 hosts?()A、Class AB、Class BC、Class CD、Class D

Given the following interface definition, which definitions are valid?()   interface I {   void setValue(int val);   int getValue();   }    DEFINITION a:   (a) class a extends I {  int value;   void setValue(int val) { value = val;  }   int getValue() {  return value;  }   }   DEFINITION b:   (b) interface b extends I {   void increment();   }   DEFINITION c:   (c) abstract class c implements I {   int getValue() {  return 0;  }  abstract void increment();   }   DEFINITION d:   (d) interface d implements I {  void increment();  }   DEFINITION e:   (e) class e implements I {  int value;   public void setValue(int val) { value = val; }  }  A、Definition a.B、Definition b.C、Definition c.D、Definition d.E、Definition e.

You are creating a Windows Forms application by using the .NET Framework 3.5. You plan to develop a new control for the application.The control will have the same properties as a TextBox control.You need to ensure that the control has a transparent background when it is painted on form.You want to achieve this goal by using the minimum amount of development effort.What should you do?()A、Create a new class that is derived from the Control class.Call the SetStyle method in the constructor.B、Create a new class that is derived from theTextBox control class.Override the OnPaint method in the constructor.C、Create a new class that is derived from the Control class.Set the BackColor property of the control to Transparent.Call the SetStyle method in the constructor.D、Create a new class that is derived from theTextBox control class.Set the BackColor property of the control to Transparent in the constructor.Call the SetStyle method in the constructor.

单选题Click the Exhibit button. 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.

多选题Given the following interface definition, which definitions are valid?()   interface I {   void setValue(int val);   int getValue();   }    DEFINITION a:   (a) class a extends I {  int value;   void setValue(int val) { value = val;  }   int getValue() {  return value;  }   }   DEFINITION b:   (b) interface b extends I {   void increment();   }   DEFINITION c:   (c) abstract class c implements I {   int getValue() {  return 0;  }  abstract void increment();   }   DEFINITION d:   (d) interface d implements I {  void increment();  }   DEFINITION e:   (e) class e implements I {  int value;   public void setValue(int val) { value = val; }  }ADefinition a.BDefinition b.CDefinition c.DDefinition d.EDefinition e.

多选题Click the Exhibit button.   Given: Which two statements are true if a NullPointerException is thrown on line 3 of class C?()AThe application will crash.BThe code on line 29 will be executed.CThe code on line 5 of class A will execute.DThe exception will be propagated back to line 27.EThe code on line 5 of class B will execute.

多选题Which two statements are true regarding the creation of a default constructor?()AThe default constructor initializes method variables.BThe default constructor invokes the no-parameter constructor of the superclass.CThe default constructor initializes the instance variables declared in the class.DIf a class lacks a no-parameter constructor,, but has other constructors, the compiler creates a default constructor.EThe compiler creates a default constructor only when there are no other constructors for the class.

多选题class A {  A() { }  }  class B extends A {  }  Which two statements are true?()AClass B’s constructor is public.BClass B’s constructor has no arguments.CClass B’s constructor includes a call to this().DClass B’s constructor includes a call to super().

多选题AnInterface is an interface. AnAdapter0 is a non-abstract, non-final class with a zero argument constructor. An Adapterl 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 ai = new Anlnterface (5)) {}

多选题Which two statements are true regarding the creation of a default constructor? ()AThe default constructor initializes method variables.BThe compiler always creates a default constructor for every class.CThe default constructor invokes the no-parameter constructor of the superclass.DThe default constructor initializes the instance variables declared in the class.EWhen a class has only constructors with parameters, the compiler does not create a default  constructor.

单选题10. class Line {  11. public static class Point { }  12. }  13.  14. class Triangle {  15. // insert code here  16. }  Which code, inserted at line 15, creates an instance of the Point class defined in Line?()A Point p = new Point();B Line.Point p = new Line.Point();C The Point class cannot be instatiated at line 15.D Line 1 = new Line() ; 1.Point p = new 1.Point();

单选题Given: Which code, inserted at line 15, creates an instance of the Point class defined in Line?()A Point p = new Point();B Line.Point p = new Line.Point();C The Point class cannot be instatiated at line 15.D Line l = new Line() ; l.Point p = new l.Point();

多选题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 X {   public static void main (String args) {   byte b = 127;   byte c = 126;   byte d = b + c;   }   }   Which statement is true?()A Compilation succeeds and d takes the value 253.B Line 5 contains an error that prevents compilation.C Line 5 throws an exception indicating “Out of range”D Line 3 and 4 contain error that prevent compilation.E The compilation succeeds and d takes the value of 1.

多选题In which two cases does the compiler supply a default constructor for class A?()Aclass A{}Bclass A { public A(){} }Cclass A { public A(int x){} }Dclass Z {} class A extends Z { void A(){} }