English 中文(简体)
抽象类别与接口之间的区别? [复制]
原标题:Difference between an abstract class and an interface? [duplicate]
This question already has answers here:
Closed 13 years ago.

Possible Duplicate:
Interface vs Base class

A class implementing an interface has to implement all the methods of the interface, but if that class is implementing an abstract class is it necessary to implement all abstract methods?
If not, can we create the object of that class which is implementing the Abstract class???

最佳回答

如果你执行一个抽象的类别,不执行所有抽象的方法,那么这一类别也必须宣布为抽象的,因此不能立即进行。

例如:

public abstract class A {

  public abstract method1();

}

public abstract class B extends A {

}

在上述例子中,您无法打电话new B();

问题回答

如果某一阶层继承一个抽象的类别,它要么必须执行所有抽象成员,要么也必须是抽象的。

因此,如果这个班子不执行所有成员,你就能够树立榜样。





相关问题
Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

JSON with classes?

Is there a standardized way to store classes in JSON, and then converting them back into classes again from a string? For example, I might have an array of objects of type Questions. I d like to ...

Object-Oriented Perl constructor syntax and named parameters

I m a little confused about what is going on in Perl constructors. I found these two examples perldoc perlbot. package Foo; #In Perl, the constructor is just a subroutine called new. sub new { #I ...

Passing another class amongst instances

I was wondering what is the best practice re. passing (another class) amongst two instances of the same class (lets call this Primary ). So, essentially in the constructor for the first, i can ...

Where can I find object-oriented Perl tutorials? [closed]

A Google search yields a number of results - but which ones are the best? The Perl site appears to contain two - perlboot and perltoot. I m reading these now, but what else is out there? Note: I ve ...

热门标签