`

about abstract class

 
阅读更多

yes, we do know abstract class cannot be instantiated, if it's extended, its constructor is not allowed to be private, that's because its derivative wants to use its super constructor which also means it'll be called associated with its derivative instantiation. let's see the following example:

 

abstract class Father {
    protected Father() {
        System.out.println("Father");
    }
}

public class Test extends Father {

    private Test() {
        System.out.println("Test");
    }

    public static void main(String[] args) {
        new Test();
    }
}

 

its output is supposed to be:

Father

Test

 

分享到:
评论

相关推荐

    java实验7.2(Auto.java Ford.java)

    Finally, write a program that uses the Auto class and subclasses to display information about different cars. The java programs should be named like: Auto.java Ford.java Chevy.java UseAuto.java ...

    java英文笔试

    **Answer**: In Java, an abstract class can have both abstract and non-abstract (concrete) methods, whereas an interface can only have abstract methods (since Java 8, interfaces can also have default ...

    Java 英文习题及答案

    Java源文件的扩展名应该是.java,而不是.class。 2. 关于Java import语句中的星号(*),以下哪个陈述是正确的? (a) I, II, and III 星号(*)不会带来运行时开销,可以用于一次性导入多个包或类。 3. 用于int类型...

    lucene-analyzers-common-5.1.0.jar

    * Class SnowballProgram is made abstract and contains new abstract method stem() to avoid reflection in Lucene filter class SnowballFilter. * All use of StringBuffers has been refactored to ...

    java实验7.1(CollegeCourse.java)

    Create an abstract Auto class with fields for the car make and price. Include get and set methods for these fields; the setPrice() method is abstract. Create two suclasses for individual automobile ...

    ejb3.0 注解 其中一部分

    public abstract class Vehicle { @Id private Long id; // ... } ``` #### 16. WebService 注解 EJB 3.0还支持WebService注解,如`@WebService`、`@SOAPBinding`、`@WebMethod`等,用于定义Web服务。 **示例...

    servlet2.4doc

    Notification that the servlet context is about to be shut down. contextInitialized(ServletContextEvent) - Method in interface javax.servlet.ServletContextListener Notification that the web ...

    JSP Simple Examples

    Unlike interface the abstract class may implement some of the methods defined in the class, but in this class at least one method should be abstract. Using Super class Variables With Sub-classed ...

    从追MM谈Java的23种设计模式

    public abstract class ChatTemplate implements Cloneable { private String content; public ChatTemplate(String content) { this.content = content; } public String getContent() { return content; ...

    Head First Go 1st Edition

    This book, rather than talking about the features of Go in abstract terms, features simple, clear examples that demonstrate Go in action, and diagrams to explain difficult concepts. This book will ...

    NETCFSERUP

    <remarks>The API class provides the capability of "reflecting" through objects to gain information at runtime about their properties. This capability provides an excellent way for application ...

    Pango Reference Manual

    Glyph Storage - Structures for storing information about glyphs Fonts - Structures representing abstract fonts Text Attributes - Font and other attributes for annotating text Tab Stops - Structures...

    PHP Objects, Patterns, and Practice(Apress,2016)

    Master advanced object-oriented features, including static methods and properties, managing error conditions with exceptions, and creating abstract classes and interfaces. Learn about the new object-...

    Professional.Python.1119070856

    Python offers many tools and techniques for writing better code, but often confusing documentation leaves many programmers in the dark about how to use them. This book shines a light on these ...

    Beginning Microsoft Visual CSharp 2008 Wiley Publishing(english)

    Interfaces Versus Abstract Classes 270 Struct Types 272 Summary 275 Exercises 276 Chapter 10: Defining Class Members 278 Member Definitions 278 Additional Class Member Topics 291 ...

    stdafx.h代码

    class CResourceException;// Win resource failure exception class CUserException; // Message Box alert and stop operation class CGdiObject; // CDC drawing tool class CPen; // a pen / HPEN wrapper...

    Professional C# 3rd Edition

    Abstract Classes and Functions 115 Sealed Classes and Methods 115 Constructors of Derived Classes 116 Modifiers 122 Visibility Modifiers 122 Other Modifiers 123 Interfaces 123 Defining and ...

    外文翻译 stus MVC

    ActionForm is an abstract class that is sub-classed for each input form model. When I say input form model, I am saying ActionForm represents a general concept of data that is set or updated by a ...

Global site tag (gtag.js) - Google Analytics