1.

Which of the below is true about java class structure?(a) The class name should start with lowercase(b) The class should have thousands of lines of code(c) The class should only contain those attribute and functionalitywhich it should; hence keeping it short(d) The class attributes and methods should be publicI have been asked this question during an interview for a job.Enquiry is from Coding best practices in division Autoboxing & Miscellaneous of Java

Answer»

Right OPTION is (c) The class should only contain those attribute and functionalitywhich it should; hence KEEPING it short

For explanation I WOULD say: Class name should always start with upper case and contain those attribute and functionality which it should (Single Responsibility Principle); hence keeping it short. The attributes should be USUALLY private with get and set methods.



Discussion

No Comment Found

Related InterviewSolutions