java中的Concrete类是什么
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/43224901/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the Concrete class in java
提问by JustCode
According to thisdocument, and many similar documents, a concrete class is described as:
根据这个文档和许多类似的文档,一个具体的类被描述为:
A concrete class in Java is any such class which has implementation of all of its inherited members either from interface or abstract class
Java 中的具体类是任何这样的类,它具有从接口或抽象类继承的所有成员的实现
And can used like this:
并且可以这样使用:
public abstract class A {
public abstract void methodA();
}
interface B {
public void printB();
}
public class C extends A implements B {
public void methodA() {
System.out.print("I am abstract implementation");
}
public void printB() {
System.out.print("I am interface implementation");
}
}
In the above example class C is a concrete class.
在上面的示例中,类 C 是一个具体类。
Is this the only way to create a concrete class. Can you give me more info about concrete class?
这是创建具体类的唯一方法吗?你能给我更多关于具体类的信息吗?
采纳答案by mdewit
A concrete class is a class that has an implementation for all of its methods that were inherited from abstract or implemented via interfaces. It also does not define any abstract methods of its own. This means that an instance of the class can be created/allocated with the newkeyword without having to implement any methods first. Therefore it can be inferred that any class that is not an abstract class or interface is a concrete class.
具体类是一个类,它具有从抽象继承或通过接口实现的所有方法的实现。它也没有定义任何自己的抽象方法。这意味着可以使用new关键字创建/分配类的实例,而无需先实现任何方法。因此可以推断,任何不是抽象类或接口的类都是具体类。
In your code above, C will be a concrete class as it implements all abstract methods inherited from A and implemented from B. Also, it does not define any abstract methods of its own.
在上面的代码中,C 将是一个具体类,因为它实现了从 A 继承并从 B 实现的所有抽象方法。此外,它没有定义任何自己的抽象方法。
回答by Lew Bloch
回答by harishhari302
A concrete class in Java is any such class which has implementation of all of its inherited members either from interface or abstract class
Java 中的具体类是任何这样的类,它具有从接口或抽象类继承的所有成员的实现
回答by Brajesh
As per name suggests, concrete means Solid, it means having no any row part or unimplemented things(methods).So we can conclude that concrete classes are those classes that can be instantiated with new key word. MyClass myClass = new MyClass();
顾名思义,concrete就是Solid,就是没有任何行部分或未实现的东西(方法)。所以我们可以得出结论,concrete类就是那些可以用new关键字实例化的类。MyClass myClass = new MyClass();
回答by Sasi
In the above program, representing abstract as public class will sometimes show some compile time errors to define that in its own file. As simple, just avoid using public keyword or modifier while using abstract class in your program to avoid some uncertainty. Any method that is invoked using new keyword (object creation) other than abstract and interface classes is called as concrete class.
在上面的程序中,将抽象表示为公共类有时会显示一些编译时错误,以在其自己的文件中定义它。很简单,在程序中使用抽象类时避免使用 public 关键字或修饰符,以避免一些不确定性。除了抽象类和接口类之外,任何使用 new 关键字(对象创建)调用的方法都称为具体类。
回答by Ganesh Chowdhary Sadanala
1.concrete class is a class which can never become an abstract or interface .It can extend or implement or both. 2.The class is said to be concrete if all its methods and variables has defined.
1.具体类是永远不能成为抽象或接口的类。它可以扩展或实现或两者兼而有之。2.如果该类的所有方法和变量都已定义,则称该类是具体的。