Exam 10: Introduction to Inheritance

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

____ polymorphism is the ability of one method to work appropriately for subclasses of the same parent class.

(Multiple Choice)
4.8/5
(42)

class Animal {       void myDog()       {           System.out.println("Animal stuff");       }   }                   class Dog extends Animal {        void mydog()       {           System.out.println("Dog stuff");       }       public static void main(String args[])       {           Dog d = new Dog();           d.myDog();           super.myDog();       }   } The above code gives a compiler error stating that the non-static variable super cannot be referenced from a static context super.myDog(); . Explain why the error occurs and describe what changes you could make for the code to be executable.

(Essay)
4.7/5
(37)

       Will the above code compile correctly? Why or why not? Explain your answer.        Will the above code compile correctly? Why or why not? Explain your answer. Will the above code compile correctly? Why or why not? Explain your answer.

(Essay)
4.8/5
(32)

What are virtual method calls?

(Essay)
4.8/5
(46)

When you create parent and child classes of your own, the child classes use ____ constructors.

(Multiple Choice)
4.9/5
(43)

You can use the ____ modifier with methods when you don't want the method to be overridden.

(Multiple Choice)
4.9/5
(33)

You use the keyword ____ to achieve inheritance in Java.

(Multiple Choice)
4.9/5
(38)

The term ____________________ means "many forms."

(Short Answer)
4.8/5
(32)

class Vehicle {} public class Car extends Vehicle {    public static void main(String args[])    {       Vehicle myCar = new Car();       boolean result =  myCar instanceof Car;       System.out.println(result);    } } The above code uses the instanceof operator to determine whether an object is a member of a class. What will be the output following execution?

(Essay)
4.7/5
(40)

An advantage to making a method ____________________ is that the compiler knows there will be only one version of the method.

(Short Answer)
4.8/5
(44)

You would like to make a member of a class visible in all subclasses regardless of what package they are in. Which one of the following keywords would achieve this?

(Multiple Choice)
4.8/5
(33)

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.

(Multiple Choice)
4.9/5
(42)

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

(Multiple Choice)
4.8/5
(38)

Create a class named Student that contains methods getGPA() , setIDNum() , and setGPA() . Be sure to declare variables and methods appropriately as public or private.

(Essay)
4.8/5
(44)

   The above code will generate an error message when compiling. Explain the error message and why it occurs. The above code will generate an error message when compiling. Explain the error message and why it occurs.

(Essay)
4.9/5
(36)

You have a Student class with a constructor that requires two arguments: a character "F" for Freshman and an integer "2020" for the year. Create a Freshman class that is a subclass of Student with a constructor for Freshman . Include the initial super() statement and include a comment that reads "//Other statements go here".

(Essay)
4.9/5
(37)

Programmers and analysts sometimes use a graphical language to describe classes and object-oriented processes. This language is called ___________________________________.

(Essay)
4.9/5
(37)

You are never aware that ____ is taking place; the compiler chooses to use this procedure to save the overhead of calling a method.

(Multiple Choice)
4.9/5
(38)

What are the parts of a class diagram and how would you use them?

(Essay)
4.9/5
(40)

You cannot declare a class to be final .

(True/False)
4.8/5
(47)
Showing 21 - 40 of 66
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)