Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(1) ____ is the principle that allows you to apply your knowledge of a general c

ID: 3571784 • Letter: #

Question

(1)     ____ is the principle that allows you to apply your knowledge of a general category to more specific objects.

          a.       Inheritance              c.       Encapsulation

          b.       Polymorphism                    d.       Override

(2)     When you create a class by making it inherit from another class, you are provided with data fields and ____ automatically.

          a.       fonts                      c.       class names

          b.       methods                  d.       arrays

(3)     By convention, a class diagram contains the ____ following each attribute or method.

          a.       data field                 c.       data type

          b.       argument                 d.       class

(4)     Conventionally, arrows used in a ____ to show inheritance relationships extend from the descendant class and point to the one from which it descends.

          a.       method diagram       c.       virtual method call

          b.       UML diagram           d.       composition

(5)     The ability to use inheritance in Java makes programs easier to write, ____ , and more quickly understood.

          a.       faster                    c.       more robust

          b.       more secure             d.       less error prone

(6)     The class used as a basis for inheritance is the ____ class.

          a.       child                       c.       base

          b.       extends                   d.       derived

(7)     You use the keyword ____ to achieve inheritance in Java.

          a.       inherit                    c.       super

          b.       extends                   d.       public

(8)     Sometimes the superclass data fields and methods are not entirely appropriate for the subclass objects; in these cases, you want to ____ the parent class members.

          a.       negate                    c.       override

          b.       overrule                  d.       hide

(9)     If a programming language does not support ____ , the language is not considered object - oriented.

          a.       syntax                    c.       loops

          b.       applets                            d.       polymorphism

(10)   ____ polymorphism is the ability of one method name to work appropriately for different subclass objects of the same parent class.

          a.       Subtype                  c.       Supertype

          b.       Name                    d.       Override

(11)   When you create a class and do not provide a(n) ____ , Java automatically supplies you with a default one.

          a.       constructor    b.       argument       c.       header          d.       name

(12)   Usually, the subclass constructor only needs to initialize the ____ that are specific to the subclass.

          a.       objects                            c.       methods

          b.       data fields                d.       constructors

(13)   When you employ ____ , your data can be altered only by the methods you choose and only in ways that you can control.

          a.       virtual method calls   c.       information hiding

          b.       polymorphism                    d.       inlining

(14)   Using the keyword ____ provides you with an intermediate level of security between public and private access.

          a.       protected      b.       this               c.       super            d.       secure

(15)   The methods in a subclass can use all of the data fields and methods that belong to its parent, with one exception: ____ members of the parent class are not accessible within a child class’s methods.

          a.       private           b.       public           c.       protected      d.       final

(16)   You can use the ____ modifier with methods when you do not want the method to be overridden.

          a.       override        b.       access           c.       final              d.       end

(17)   Which of the following statements will create a class named Red that is based on the class Color ?

          a.       public class Red extends Color         

          b.       public Red class extends Color

          c.       public Color class expands Red

          d.       public extend Red class Color

(18)   Which of the following statements depicts the valid format to call a superclass constructor from a subclass constructor?

          a.       superclass(name, score);     c.       extends(name, score);

          b.       subclass(name, score);       d.       super(name, score);

(19)   If jrStudent is an object of Student, which of the following statements will result in a value of true?

          a.       Student = instanceof jrStudent         

          b.       jrStudent instanceof Student            

          c.       instanceof Student = jrStudent

          d.       Student instanceof jrStudent

(20)   Which statement correctly declares a sedan object of the Car class?

          a.       sedan Car = new sedan();          c.       Car sedan = new Car();

b.       sedan Car = new sedan();          d.       new sedan() = Student;

Explanation / Answer

1. Option a. Inheritance is the principle that allows you to apply your knowledge of a general category to more specific objects.

2. Option b. methods

The methods and data fields are automatically inherited when you create a class by making it inherit from another class.

3. Option c. data type

A class diagram contains the data type following each attribute or method.

4. Option b. UML diagram

In UML diagram, the arrows are used to show inheritance relationships extend from the descendant class and point to the one from which it descends.

5. Option d. less error prone

The ability to use inheritance in Java makes programs easier to write, less error prone, and more quickly understood.

6. Option c. base class

The class used as a basis for inheritance is the base class.

7. Option b. extend

The keyword extends is used to achieve the inheritance in java.

8. Option c. override

Sometimes the superclass data fields and methods are not entirely appropriate for the subclass objects; in these cases, you want to override the parent class members.

9. Option d. polymorphism

If a programming language does not support polymorphism, the language is not considered object - oriented.

10. Option c. Subtype

Subtype polymorphism is the ability of one method name to work appropriately for different subclass objects of the same parent class.

11. Option a. constructor   

Java automatically supplies you with a default constructor, when creating a class without the constructor.

12. Option b. data fields

The subclass constructor only needs to initialize the data fields that are specific to the subclass.

13. Option c. information hiding

In information hiding, data can be altered only by the methods you choose and only in ways that you can control.

14. Option a. protected

The protected keyword provides you with an intermediate level of security between public and private access.

15. Option a. private

The private members of the parent class are not accessible within a child class’s methods.

16. Option c. final

The final is used for the modifier with methods when you do not want the method to be overridden.

17. Option a. public class Red extends Color

Here Color is the base class and Red the child class.

18. Option a. superclass(name, score);

19. Option b. jrStudent instanceof Student

20. Option c. Car sedan = new Car();