Review Questions
- In your own words, describe generalization and specialization.
- Define and contrast the terms single inheritance and multiple inheritance.
- Give an example of multiple inheritance in a real-life situation.
- What is the function of the import statement?
- A and B are two classes. If A inherits properties from B, then A is a ___________ class of B, and B is a __________ class of A.
- How does inheritance contribute to software reusability?
- Distinguish between contract inheritance and implementation inheritance.
- Discuss the problem associated with multiple inheritance. How does Java overcome this problem, and what feature is provided in Java to achieve multiple inheritance? Discuss the limitation of this feature.
- What is the expected output of the following code?
interface I {
void x();
void y();
}
class A implements I {
A() {}
public void w() {System.out.println("in A.w");}
public void x() {System.out.println("in A.x");}
public void y() {System.out.println("in A.y");}
}
class B extends A {
B() {}
public void y() {
System.out.println("in B.y");
}
void z() {
w();
x();
}
static public void main(String args[]) {
A aa = new A();
B bb = new B();
bb.z();
bb.y();
}
}
- Discuss the two facilities required by programming languages to support polymorphism.
- How does polymorphism contribute to software maintainability?
- What is the difference between method overloading and overriding?
- What is a “HashMap”?
- What is a hash code, and how is it used with a “HashMap”?
- What are the advantages and disadvantages of “ArrayList” and “LinkedList”?
- What are the advantages and disadvantages of “TreeSet” and “HashSet”?
- What are the advantages and disadvantages of “TreeMap”, “HashMap”, and “HashTable”?
- How do you make a collection/map unmodifiable?
- Why are there unsupported operations in the collections?
- What are the four levels of access specification in Java?
- What is a compilation unit in Java?
- What is automatic downloading of classes?
- What is the naming convention for packages?
- What is the package caveat?
- What is “friendly” access?
- What is “public” access?
- What is “private” access?
- What is “protected” access?
- What is the convention for ordering variables by access level?
- What are two constraints of using the public access level?
- What are the two main reasons for access control?
- How does “protected” work with inheritance?
- What does the keyword “extend” accomplish?
- Why would a programmer write a clean-up method?
- What are two ways of setting a final primitive value?
- What is the difference between “static final” and “final”?
- What is the effect of final on objects?
- What is the advantage of using a blank final?
- How does a final argument function?
- What is an advantage of a final method?
- Why should one be cautious when using a final method?
- What is the ordering of events in initialization and class loading?
- What is the role of late binding in polymorphism?
- How is extensibility supported by polymorphism?
- What is the difference between overloading and overriding, and how can they be confused?
- What are abstract classes and abstract methods?
- What is the order of constructor calls for base and derived classes?
- What is the order of “finalize” for base and derived classes?
- How does an interface differ from an abstract class?
- How is multiple inheritance dealt with by interfaces?
- Can a class implement multiple interfaces?
- How does extend differ for interfaces?
- How do interfaces differ with regard to final variables?
- What is an inner class?
- What is the advantage of defining a class within a method or a scope?
- What access do inner classes have to the containing class variables and methods?
- How do inner classes create a situation that looks like multiple inheritance?
- What are two ways of initializing arrays?
- How do you implement “Comparable” when sorting an array?
- How do you implement “Comparator” when sorting an array?
- What are the two main concepts underlying the Java 2 collections library?
- What is the disadvantage of the collections library?
- How do you make a type-conscious “ArrayList” in Java?
- How do you use an interface to work with your implementation of the collections library?
- What is the advantage of an “ArrayList”?
- What are the two implementations of sets?
- What is an associative array?
Updated July 30 2020 by FST Course Production Staff