单选题 现有: class Cat { Cat (int c) {System.out.print ("cat"+c+" "); } } class SubCat extends Cat { SubCat (int c){super (5); System.out.print ("cable");} . SubCat() { this (4); } public static void main (String [] args) { SubCat s= new SubCat();//调用无参的 } } 结果为:

A、 cat5
B、 cable
C、 cat5 cable
D、 cable cat5
下载APP答题
由4l***6c提供 分享 举报 纠错

相关试题

单选题 假设People类有如下定义,设p是People类的一个实例,下列语句调用哪个是错误的? 答案( ) public class People{ int i; static String s; void imethod() { } static void smethod() { }}

A、p.imethod()
B、People.imethod();
C、System.out.println(p.i);
D、People.smethod()

单选题 若int[] a = {12,43,54,23},则a[3]的值是( )

A、12
B、43
C、54
D、23

单选题 class Line{ private int x,y; public Line(int x,int y){ this.x=x; this.y=y; }}其中this代表( )

A、类名Line
B、父类的对象
C、Line类实例的当前对象引用
D、this指针

单选题 java实现动态多态性是通过( )实现的。

A、重载
B、覆盖
C、接口
D、抽象类

单选题 下列【1】【2】【3】【4】注释标注的哪行代码有错误?( )import java.util.*; public class E { public static void main(String args[]) { List<Integer> linkedList = new LinkedList<Integer>(); //【1】 List<Integer> arryList = new ArrayList<Integer>(); //【2】 Set<Integer> hashSet = new HashSet<Integer>(); //【3】 List<Integer> set = new TreeSet<Integer>(); //【4】 } }

A、【1】
B、【2】
C、【3】
D、【4】

单选题 程序: public class Pet{ public void speak(){ System.out.print("Pet"); } } public class Cat extends Pet{ public void speak(){ System.out.print("Cat"); } } public class Dog extends Pet{ public void speak(){ System.out.print("Dog"); } } 执行代码 Pet[] p= {new Cat (),new Dog(),new Pet()}; for (int i=0;i

A、Pet Dog Cat
B、Cat Cat Cat
C、Cat Dog Dog
D、Cat Dog Pet

单选题 下面程序运行的结果是( ) public static void main(String[] args){ int a = 1; if(a < 1){ System.out.println(a); }else{ System.out.println(“a”); } }

A、a
B、2
C、1
D、编译报错

单选题 下列有关线程的两种创建方式说法错误的是( )

A、通过继承Thread类与实现Runnable接口都可以创建多线程程序
B、实现Runnable接口相对于继承Thread类来说,可以避免由于Java的单继承带来的局限性
C、通过继承Thread类与实现Runnable接口创建多线程这两种方式没有区别
D、大部分的多线程应用都会采用实现Runnable接口方式创建