以下程序是正确的。 class IamAbstract { final int f; double d; abstract void method1(); } 。()此题为判断题(对,错)。

题目
以下程序是正确的。 class IamAbstract { final int f; double d; abstract void method1(); } 。()

此题为判断题(对,错)。


相似考题
更多“以下程序是正确的。 class IamAbstract { final int f; double d; abstract void method1(); } 。() ”相关问题
  • 第1题:

    下列选项成员变量声明正确的是

    A.public protected final int i;

    B.abstract class F1{…}

    C.private double height;

    D.double weight{}


    正确答案:C
    解析:本题考查对成员变量的声明。成员变量的声明格式位:修饰符type变量名;其中type可以是java语言中的任意数据类型,而修饰符可以是public、protected, private,static,final,transient,volatile等。选项A错误,成员变量不能同时声明成 public和protected。选项B是类的声明格式,并不是成员变量的声明。成员变量声明应以“;”结尾,选项D错误。选项C声明了一个私有的double型成员变量,为正确答案。

  • 第2题:

    下列选项成员变量声明正确的是( )。

    A.public protected final int i;

    B.abstract class Fl{…}

    C.private double height;

    D.double weight


    正确答案:C
    C。【解析】本题考查对成员变量的声明。成员变量的声明格式为:修饰符type变量名;其中type可以是java语言中的任意数据类型,而修饰符可以是public、protected,private,static,final,transient,volatile等。选项A错误,成员变量不能同时声明成public和protected。选项B是类的声明格式,并不是成员变量的声明。成员变量声明应以";"结尾,选项D错误。选项C声明了一个私有的double型成员变量,为正确答案。

  • 第3题:

    下列哪个成员方法声明是正确的? ( )

    A.public abstract final int f(){...}

    B.public static boolean f(){...}

    C.static protected void g(a,{...}

    D.protected private number;


    正确答案:B
    解析:本题考查对成员方法声明的掌握程度。选项A错误,成员变量不能同时声明成abstract和final;选项B正确,声明了一个公有静态返回值类型是布尔类型的方法f();选项C错误,protected应在static之前;选项D错误,既不是方法声明,也不是正确的成员变量声明。

  • 第4题:

    分析下面程序,哪一行代码能正确赋值?()class Demo {public void method() {final int num1 = 10;static int num2 = 20;abstract int num3 = 30;private int num4 = 40;}}

    A.final int num1 = 10;

    B.static int num2 = 20;

    C.abstract int num3 = 30;

    D.private int num4 = 40;


    答案:A
    解析:final可以修饰局部变量


    解析:虽然是运行时期异常,但是也可以使用try…catch语句进行处理。一旦进入处理语句就不会再回去执行

  • 第5题:

    下列程序的运行结果是______。 include class Base { public: virtual void func(int

    下列程序的运行结果是______。

    include<iostream.h>

    class Base

    {

    public:

    virtual void func(int i){cout<<"class Base:"<<i<<end1;)

    };

    class Derived: public Base

    {

    public:

    void func(double d){cout<<"class Derived:"<<d<<endl;}

    };

    void main( )

    {

    Base a,*p=a;

    Derived b;

    p=&b;

    (*p).func(3.3);

    }


    正确答案:class Base:3
    class Base:3 解析:题中基类和派生类中有同名函数,但是参数不同。派生关系中,只有在函数类型、函数名和参数个数、参数类型完全相同时,才表现多态性。本题中参数不同,编译器便认为是两个完全不同的函数。通过基类的指针指向派生类对象时,该指针只能访问到派生类中具有多态性的成员函数,而与基类无关的函数是无法通过基类指针来访问的。故调用的是base类的 func函数,系统将3.3强制转化为整型数3。如果将派生类中的func的形参改为int型,则执行的就会是派生类的func函数,此时表现为多态。

  • 第6题:

    以下语句可以通过编译: abstract class am_I_abstract { abstract void method1(); }。()

    此题为判断题(对,错)。


    答案:对

  • 第7题:

    设有程序如下: abstract class absclass { abstract void method1(); } class conclass extends absclass { public void method1() { System.out.println("子类");} } public class mainclass { public static void main(String args[]) { absclass ac1=new absclass(); //语句1 absclass ac2=new conclass(); //语句2 ac2.method1(); //语句3 } } 则main()方法中的第一条语句(即语句1)可以顺利通过编译。()

    此题为判断题(对,错)。


    答案:错

  • 第8题:

    Which will declare a method that is available to all members of the same package and can be referenced  without an instance of the class?()  

    • A、 Abstract public void methoda();
    • B、 Public abstract double methoda();
    • C、 Static void methoda(double d1){}
    • D、 Public native double methoda(){}
    • E、 Protected void methoda(double d1){}

    正确答案:C

  • 第9题:

    以下声明合法的是()

    • A、default  String  s
    • B、public  final  static  native  int  w( )
    • C、abstract  double  d
    • D、abstract  final  double  hyperbolicCosine( )

    正确答案:B

  • 第10题:

    public abstract class Shape {  private int x;  private int y;  public abstract void draw();  public void setAnchor(int x, int y) {  this.x = x;  this.y = y;  }  }  Which two classes use the Shape class correctly?()

    • A、 public class Circle implements Shape { private int radius; }
    • B、 public abstract class Circle extends Shape { private int radius; }
    • C、 public class Circle extends Shape { private int radius; public void draw(); }
    • D、 public abstract class Circle implements Shape { private int radius; public void draw(); }
    • E、 public class Circle extends Shape { private int radius;public void draw() {/* code here */} }
    • F、 public abstract class Circle implements Shape { private int radius;public void draw() { / code here */ } }

    正确答案:B,E

  • 第11题:

    单选题
    Which will declare a method that is available to all members of the same package and can be referenced without an instance of the class?()
    A

     Abstract public void methoda();

    B

     Public abstract double methoda();

    C

     Static void methoda(double d1){}

    D

     Public native double methoda()  {}

    E

     Protected void methoda(double d1)  {}


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

  • 第12题:

    多选题
    class BaseClass{  private float x= 1.0f;  protected void setVar (float f) {x = f;}  }  class SubClass extends BaseClass   {  private float x = 2.0f;  //insert code here  }   Which two are valid examples of method overriding?()
    A

    Void setVar(float f) {x = f;}

    B

    Public void setVar(int f) {x = f;}

    C

    Public void setVar(float f) {x = f;}

    D

    Public double setVar(float f) {x = f;}

    E

    Public final void setVar(float f) {x = f;}

    F

    Protected float setVar() {x=3.0f; return 3.0f; }


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

  • 第13题:

    下列成员变量声明中,正确的是______。

    A.public protected final int i;

    B.abstract class F1{…}

    C.private double height;

    D.double weight


    正确答案:C
    解析: 成员变量的修饰符可以是public、protected、private、static、final、transient、volatile等,选项A错误。成员变量不能同时声明成public和protected。选项B是类的声明格式,并不是成员变量的声明。成员变量声明应以“;”结束,选项D不正确。选项C声明一个私有的double型成员变量,此为正确答案。

  • 第14题:

    下列哪个成员变量声明是正确的? ( )

    A.public protected final iht i;

    B.abstract class F9{...}

    C.private double height;

    D.double weight{}


    正确答案:C
    解析:本题考查对成员变量声明的掌握程度。选项A错误,成员变量不能同时声明成public和protected;选项B错误,不是成员变量声明,是类声明;选项C正确,声明了一个double类型的私有变量height;选项D错误,不能以“{}”结尾,应用“;”。

  • 第15题:

    下列程序片段中,能通过编译的是( )。 A.public abstract class Animal{ public void speak;}S

    下列程序片段中,能通过编译的是( )。

    A.public abstract class Animal{ public void speak;}

    B.public abstract class Animal{ public void speak{);}

    C.public class Animal{ pubilc abstract void speak;}

    D.public abstract class Animal{ pubile abstract void speak{};}


    正确答案:A
    A。【解析】Java中一个类是一个abstract类的子类,它必须具体实现父类的abstract方法。如果一个类中含有abstract方法,那么这个类必须用abstract来修饰(abstract类也可以没有abstract方法)。有abstract方法的父类只声明,由继承它的子类实现。所以选A。

  • 第16题:

    下列哪个成员方法声明是正确的? ( )

    A.public abstract final int f(){…}

    B.public static boolean f(){…}

    C.static protected void g(a,b){…}

    D.protected private number;


    正确答案:B
    解析:本题考查对成员方法声明的掌握程度。选项A错误,成员变量不能同时声明成abstract 和 final;选项B正确,声明了一个公有静态返回值类型是布尔类型的方法 f();选项C错误,protected应在static之前;选项D错误,既不是方法声明,也不是正确的成员变量声明。

  • 第17题:

    以下语句可以通过编译: class am_I_abstract { abstract void method1(); } 。()

    此题为判断题(对,错)。


    答案:错

  • 第18题:

    以下语句能顺利通过编译: class class1 { private final void method1() {} }。()

    此题为判断题(对,错)。


    答案:对

  • 第19题:

    { IamAbstract ia=new IamAbstract(); } abstract class IamAbstract { IamAbstract(){} } 。()

    此题为判断题(对,错)。


    答案:错

  • 第20题:

    Which will declare a method that is available to all members of the same package and be referenced without an instance of the class?()

    • A、 abstract public void methoda ();
    • B、 public abstract double inethoda ();
    • C、 static void methoda (double dl) {}
    • D、 public native double methoda () {}
    • E、 protected void methoda (double dl) {}

    正确答案:C

  • 第21题:

    class BaseClass{  private float x= 1.0f;  protected void setVar (float f) {x = f;}  }  class SubClass extends BaseClass   {  private float x = 2.0f;  //insert code here  }   Which two are valid examples of method overriding?()        

    • A、 Void setVar(float f) {x = f;}
    • B、 Public void setVar(int f) {x = f;}
    • C、 Public void setVar(float f) {x = f;}
    • D、 Public double setVar(float f) {x = f;}
    • E、 Public final void setVar(float f) {x = f;}
    • F、 Protected float setVar() {x=3.0f; return 3.0f; }

    正确答案:C,E

  • 第22题:

    多选题
    public abstract class Shape {  private int x;  private int y;  public abstract void draw();  public void setAnchor(int x, int y) {  this.x = x;  this.y = y;  }  }  Which two classes use the Shape class correctly?()
    A

    public class Circle implements Shape { private int radius; }

    B

    public abstract class Circle extends Shape { private int radius; }

    C

    public class Circle extends Shape { private int radius; public void draw(); }

    D

    public abstract class Circle implements Shape { private int radius; public void draw(); }

    E

    public class Circle extends Shape { private int radius;public void draw() {/* code here */} }

    F

    public abstract class Circle implements Shape { private int radius;public void draw() { / code here */ } }


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

  • 第23题:

    单选题
    Which will declare a method that is available to all members of the same package and be referenced without an instance of the class?()
    A

     abstract public void methoda ();

    B

     public abstract double inethoda ();

    C

     static void methoda (double dl) {}

    D

     public native double methoda () {}

    E

     protected void methoda (double dl) {}


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