下列各种java类的定义,那种是错误的
A: class Animal{}class Dog extends Animal {}
B: final class Animal{}class Dog extends Animal{}
C: abstract class Animal{}class Dog extends Animal{}
D: public class Animal{}class Dog extends Animal{}
A: class Animal{}class Dog extends Animal {}
B: final class Animal{}class Dog extends Animal{}
C: abstract class Animal{}class Dog extends Animal{}
D: public class Animal{}class Dog extends Animal{}
举一反三
- (7-1)定义了Animal类、Cat类和Dog类,则代码段是正确的。 class Animal{ }; class Cat extends Animal{} class Dog extends Animal{}
- class Animal { public Animal() { System.out.println("Animal!"); } } public class Dog extends Animal{ public Dog() { System.out.println("Dog!"); } public static void main(String[] args) { Dog dog=new Dog(); } }
- 判断如下代码是否存在1处语法错误(正好存在1处错误为正确,少于1处或者多余1处都为错误):public class Animal{ }class Dog extends Animal{ String name; public Dog(){ this.name = "阿毛"; super();}}
- 请阅读下面的程序,写出运行结果,如果编译失败,写明失败原因。 abstract class Animal{ public final abstract void eat(); } class Cat extends Animal{ public void eat(){ System.out.println("cat...fish"); } } class CatDemo{ public static void main(String[] args){ Animal a = new Cat(); a.eat(); } }
- 下面关于抽象类定义合法的是( ) A: class Animal { abstract void grow(); } B: abstract Animal { abstract void grow(); } C: class abstract Animal { abstract void grow(); } D: abstract class Animal { abstract void grow(); }