Which of the following statements are true?
a. A class should describe a single entity and all the class operations should logically fit together to support a coherent purpose.
b. A class should always contain a no-arg constructor.
c. The constructors must always be public.
d. The constructors may be protected.
ad (B) is not true. Most classes have a no-arg constructor. But sometimes, it does not make any sense to provide a no-arg constructor. For example, StringTokenizer does not have a no-arg constructor. (C) is not true. For example, the constructor in the Math class is private to prevent creating instances from the class, because there is no need to create instances for the Math class since all methods are static in Math. The constructors for abstract classes should be protected in most cases.
You might also like to view...
What is a building block? Does Word provides a predefined list of building blocks? If yes, where can you find this list?
What will be an ideal response?
A user is experiencing slow connections. Which of the following commands would be used to determine the delay time between the hops?
A. tracert B. nbtstat C. nslookup D. ping