简体   繁体   中英

What is the Concrete class in java

According to this document, 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

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.

Is this the only way to create a concrete class. Can you give me more info about concrete class?

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 new keyword 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.

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.

具体类的最简单定义是它是一个非抽象的类。

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();

Java中的具体类是任何这样的类,它可以从接口或抽象类实现其所有继承成员

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM