ITSC Final review
When one object is a specialized version of another object, there is this type of relationship between them
"is a"
If a class contains an abstract method
- You must create an instance of the class -The method cannot be overridden in derived classes - The method will have only a header, but not a body, and end with a semicolon
True of false An abstract class is not instantiated, but serves as a superclass for other classes
True
True or false All methods in an abstract class must also be declared abstract
True
True or false Every class has a toString method and an equals method inherited from the object class
True
True or false In an inheritance relationship, the derived class constructor always executes before the base class
True
True or false It is not possible for a superclass to call a subclass's method
True
When an "is a" relationship exists between objects, it means that the specialized object has
All the characteristics of the general object, plus additional characteristics
True of false: If a method in a subclass has the same signature as a method in the superclass, the subclass method overloads the superclass method
False
True or false When an interface variable references an object, you can use the interface variable to call all the methods in the class implementing the interface
False
T or F: If a sublclass constructor does not explicitly call a superclass constructor, the JVM will not call any of the superclasses constructors
False The JVM automatically inserts a call to the no-arg constructor of the superclass
True or false It two methods in the same class have the same name but different signatures, the second overrides the first
True
In the following statement, which is the superclass? public class ClassA extends ClassB implements ClassC
ClassB
When you write code that may cause a checked exception to be thrown(such as an IOException), you have two options to get the code to compile. What are the two options
Must invoke the exception in a try-catch block or declare to throw the exception in the calling method
Can a subclass ever directly access the private members of its superclass?
No, private members of a super class cannot be access in subclass
All classes directly or indirectly inherit from what class?
Object
Every class is either directly of indirectly derived from what class?
Object class
A subclass can directly access
Only public and protected members of the superclass class
A method in a subclass having the same name as a method in the superclass but a different signature is an example of
overloading
A method in a subclass having the same signature as a method in the superclass is an example of
overriding
Which access specifier gives access to members(fields or methods) to any subclasses?
public
Which of the following statements declares Salaraied as subclass of PayType?
public class Salaried extends PayType
Given the following code which of the following is true? public class ClassB implements ClassA
ClassB must override each method in ClassA
What does it mean to implement an interface?
Inheriting the abstract methods of the inheritance
In the following code, what will call to super do? public class ClassB extends ClassA { public ClassB() { super(40); System.out.println("THis is the last statement "); }
It will call the constructor of ClassA that receives an integer as an argument
Look at the following code to determine what the call to super will do. public class ClassB extends ClassA { public ClassB() { super(10); } }
It will call the constructor of ClassA that receives an integer as an argument
If a subclass constructor does not explicitly call a superclass constructor
Java will automatically call the superclass's default constructor immediately after the code in the subclass's constructor executes