If we print any object by using println() or print() methods The println() or print() methods internally calls tostring() method and prints the return value of toString() method
Correct Answer: If constructor opens the file finalize() method closes that file If constructor opens the connection finalize() method closes that connection To perform finalization operation we must overriding finalize method
2. What is the purpose of overriding toString() method?
Correct Answer: Final method is a method defined in the super class with final modifier We cannot overriding final method of super class in the sub class EX: Class Sample { final void funOne() { } void funTwo() { } } Class Sub extends Sample { void funOne() { // overriding is not allowed } viod funTwo() { //overriding is allowed } }
4. What is the use of overloading ? or why overloading?
Correct Answer: - By using method overriding a sub class can change the definition of super class method - By using overriding a sub class can modify the functionality of the super class
Correct Answer: Interface data is static data why bcoz interface supports multiple inheritance if inteface data is non-static then there is chance for replication of the data (bcoz of replication of data ambiguity problem occurs )
Correct Answer: to access non-public data outside class getter methods be defined but we cannot define a method inside interface we can declared a method inside interface