CMSC132 Study Guide 3
What methods are in the Comparable interface? – answer compare To()
What methods are in the Comparator interface? – answer compare()
You cannot instantiate an abstract class. - answer True
An abstract class allows inheritance. - answer True
An abstract class is useful for polymorphism - answer True
If a class contains an abstract method then the class must be declared as abstract -
answer True
If a class is declared as abstract then the class must contain at least one abstract
method - answer False
Code inside the abstract class can make calls to methods of the class that are declared
abstract - answerTrue
A concrete (non-abstract) class extending an abstract class must provide
implementations for the abstract methods of the class - answerTrue
An abstract class can be used as a type - answerTrue
An abstract class can be used as the type for a "polymorphic collection" - answerTrue
Name an advantage of using interfaces over abstract classes - answerAn advantage of
interfaces is that you can implement as many interfaces as you want in a class.
Name an advantage of using abstract classes over interfaces - answerAn advantage of
abstract classes is inheritance.
You should be prepared to write Junit tests -
answerhttp://www.cs.umd.edu/eclipse/JUnitTesting.html
When should you "throw" an exception? - answerWhen an exceptional event has
occurred that might break your code
Describe Java exception handling in detail. Be sure to mention "throw", "catch", and the
role of the call stack. - answer-pops off each stack until it finds catch block, if not
terminate program, will not run code until it find catch block.
What methods are in the Comparable interface? – answer compare To()
What methods are in the Comparator interface? – answer compare()
You cannot instantiate an abstract class. - answer True
An abstract class allows inheritance. - answer True
An abstract class is useful for polymorphism - answer True
If a class contains an abstract method then the class must be declared as abstract -
answer True
If a class is declared as abstract then the class must contain at least one abstract
method - answer False
Code inside the abstract class can make calls to methods of the class that are declared
abstract - answerTrue
A concrete (non-abstract) class extending an abstract class must provide
implementations for the abstract methods of the class - answerTrue
An abstract class can be used as a type - answerTrue
An abstract class can be used as the type for a "polymorphic collection" - answerTrue
Name an advantage of using interfaces over abstract classes - answerAn advantage of
interfaces is that you can implement as many interfaces as you want in a class.
Name an advantage of using abstract classes over interfaces - answerAn advantage of
abstract classes is inheritance.
You should be prepared to write Junit tests -
answerhttp://www.cs.umd.edu/eclipse/JUnitTesting.html
When should you "throw" an exception? - answerWhen an exceptional event has
occurred that might break your code
Describe Java exception handling in detail. Be sure to mention "throw", "catch", and the
role of the call stack. - answer-pops off each stack until it finds catch block, if not
terminate program, will not run code until it find catch block.