Which declare a compilable abstract class
Abstraction helps in reducing programming complexity and effort. These classes can have abstract methods as well as concrete methods. A normal class cannot have abstract methods. An abstract class is a class that contains at least one abstract method. We can understand the concept by the shape example in java.
Consider the following class hierarchy consisting of a Shape class which is inherited by three classes Rectangle, Circle, and Triangle. The Shape class is created to save on common attributes and methods shared by the three classes Rectangle, Circle, and Triangle. Now, assume you write code to create objects for the classes depicted above. An object of the class rectangle will give a rectangle, a shape we so commonly observed in everyday life. If you observe the Shape class serves in our goal of achieving inheritance and polymorphism.
But it was not built to be instantiated. Such classes can be labelled Abstract. An abstract java class cannot be instantiated. But such object will have no use in your code and will open a room for potential errors.
F uses invalid instantiation syntax. B, C, D, E , and F are incorrect; these lines all use correct syntax. D and F are correct. Line 5 is the only line that will not compile, because enums cannot be local to a method. Previous page.
Table of content. Next page. Given the following, 1. Choose all that apply. Which declare a compilable abstract class? Which is true? Which are valid declarations?
Which method names follow the JavaBeans standard? Given: 1. Which are legal declarations? The code compiles. If only line 1 is removed the code compiles. If only line 3 is removed the code compiles. C is incorrect becauseyou can't have an abstract method unless the class is abstract. D is incorrect because thekeyword abstract must come before the classname. Objective 1. Which is true?
B is incorrect because interfaces only "inherit from" other interfaces. D is incorrect based on the preceding rules. Given: 1. String sound; 4. What is the result? Multiple compilation errors C. Compilation fails due to an error on line 2 D. Compilation fails due to an error on line 3 E.
0コメント