热门面试题与答案和在线测试
面向面试准备、在线测试、教程与实战练习的学习平台

通过聚焦学习路径、模拟测试和面试实战内容持续提升技能。

WithoutBook 将分主题面试题、在线练习测试、教程和对比指南整合到一个响应式学习空间中。

面试准备

Core Java 面试题与答案

Test your skills through the online practice test: Core Java Quiz Online Practice Test

问题 76. What are abstract classes, abstract methods?

Simply speaking a class or a method qualified with "abstract" keyword is an abstract class or abstract method. You create an abstract class when you want to manipulate a set of classes through a common interface. All derived-class methods that match the signature of the base-class declaration will be called using the dynamic binding mechanism. If you have an abstract class, objects of that class almost always have no meaning. That is, abstract class is meant to express only the interface and sometimes some default method implementations, and not a particular implementation, so creating an abstract class object makes no sense and are not allowed ( compile will give you an error message if you try to create one). An abstract method is an incomplete method. It has only a declaration and no method body. Here is the syntax for an abstract method declaration: abstract void f(); If a class contains one or more abstract methods, the class must be qualified an abstract. (Otherwise, the compiler gives you an error message.). It's possible to create a class as abstract without including any abstract methods. This is useful when you've got a class in which it doesn't make sense to have any abstract methods, and yet you want to prevent any instances of that class. Abstract classes and methods are created because they make the abstractness of a class explicit, and tell both the user and the compiler how it was intended to be used.
For example:

abstract class Instrument { 
	int i; // storage allocated for each 
	public abstract void play(); 
	public String what() { 
		return "Instrument";
	}	
	public abstract void adjust(); 
} 

class Wind extends Instrument { 
	public void play() { 
		System.out.println("Wind.play()"); 
	} 
	public String what() { 
		return "Wind"; 
	} 
	public void adjust() {}
}
Abstract classes are classes for which there can be no instances at run time. i.e. the implementation of the abstract classes are not complete. Abstract methods are methods which have no defintion. i.e. abstract methods have to be implemented in one of the sub classes or else that class will also become Abstract.

这有帮助吗? 添加评论 查看评论
 

问题 77. What does the "abstract" keyword mean in front of a method? A class?

Abstract keyword declares either a method or a class.
If a method has a abstract keyword in front of it,it is called abstract method.Abstract method hs no body.It has only arguments and return type.Abstract methods act as placeholder methods that are implemented in the subclasses.
Abstract classes can't be instantiated.If a class is declared as abstract,no objects of that class can be created.If a class contains any abstract method it must be declared as abstract

这有帮助吗? 添加评论 查看评论
 

问题 78. What is the purpose of abstract class?

It is not an instantiable class. It provides the concrete implementation for some/all the methods. So that they can reuse the concrete functionality by inheriting the abstract class.

这有帮助吗? 添加评论 查看评论
 

问题 79. How to define an Abstract class?

A class containing abstract method is called Abstract class. An Abstract class can't be instantiated.
Example of Abstract class:

abstract class testAbstractClass {
	protected String myString; 
	public String getMyString() { 
		return myString; 
	} 
	public abstract string anyAbstractFunction();
}

这有帮助吗? 添加评论 查看评论
 

问题 80. Can there be an abstract class with no abstract methods in it?

Yes

这有帮助吗? 添加评论 查看评论
 
5) Can there be an abstract class with no abstract methods in it? " />

用户评价最有帮助的内容:

版权所有 © 2026,WithoutBook。