Need some verification! True/False - 1. All methods in an abstract class must be
ID: 3628512 • Letter: N
Question
Need some verification!
True/False -
1. All methods in an abstract class must be abstract
2. An abstract class may provide constructors?
3. A clas may extend more than one class?
4. A class may implement more than one interface?
5. A class may extent one class and implement one interface?
6. An interface may implement some of it's methods?
7. All methods in an interface must have a void return type?
8. Throwable is an interface
9. Comparable is an interface
10. Comparator is an example of an interface that is used for function objects?
Explanation / Answer
1. FALSE: Abstract classes are not required to have any abstract methods.It contain a set of functional, integrated methods but have no practical use in its basic form, 2.TRUE: This may sound odd, but an abstract class may have constructors, but they cannot be used to instantiate the abstract class. If you write statements to call the constructor the compiler will fail and report the class is "abstract; cannot be instantiated". Constructors in abstract classes are designed only to be used by their subclasses using a super() call in their own constructors. Though the abstract class cannot stand as an instance in its own right, when its abstract methods are fulfilled by a subclass, its constructors can be called upon to deliver stock template-like initialisation behaviour 3: TRUE in C++ In java it is wrong. but in C++ it is TRUE. 4. TRUE in java class A implements < interface Name 1>, < interface Name 2> 5. TRUE in java class A extends class B implements < interface> 6. FALSE 7. TRUE: public interface TestServiceAsync {public void testMethod(String param, AsyncCallback callback);
} 8. FALSE: Throwable is a class not a interface. It is the superclass of all errors and exceptions in the Java language 9. TRUE: public interface Comparable: An interface imposes a total ordering on the objects of each class that implements it. This ordering is referred to as the class's natural ordering, and the class's compareTo method is referred to as its natural comparison method. 10: FALSE: A comparator is an interface that can be used to create objects to pass to sort methods or sorting data structures.
A Comparator must define a compare function which takes two Objects and returns a -1, 0, or 1.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.