Make the constructor private. Uhm, how would you make a instance of this class then? Why don't you want inheritance? I don't understand!
Answer:
You can create the class without the public declaration. In such a case the access for that class would be default and hence you cannot extend that specific class outside its package. Still you can extend this class within its package.
The purpose of having the final keyword is to ensure that the class is not inherited. doing it without final is like touching your nose around your head when you can do it straightaway...
If a class is declared as final, you can't inherit from it. If individual methods are declared final, then, if the class is inherited, these methods can't be changed in the inherited classes.
Declare the class as final. final class A{ ... }
You can declare a class as "final".
Java does not support multiple inheritance.......
we can use classes in java...by inheritance concept...we can reuse without modification
Java does not support multiple inheritance
Java does not support direct multiple inheritance. You can implement partial multiple inheritance using interfaces. ex: public class ExMultInherit implements interface1, interface2, interface 3 { ... .... ...... }
Java does not allow the multiple inheritance of concrete classes, though it does allow a "hybrid" inheritance of one concrete class and multiple interfaces.
Java does not support direct multiple Inheritance. Harder to implement, not every language support it: C++ does, Java does not.
Java does not support multiple inheritance. It is done with the help of interfaces in java. a class can implement n number of interfaces, thus showing multiple inheritance. but a class cannot extend multiple classes in java.
Inheritance is a Java feature by which we can reuse code and programming logic from one class in another class. We implement Inheritance using the extends keyword.Ex: public class Ferrari extends Car {…}Here the Ferrari Class will extend features from the Car Class.This is Inheritance. The different types of Inheritance are:Single InheritanceMulti-Level InheritanceMultiple Inheritance (Java supports only Partial Multiple Inheritance) andHybrid Inheritance
Inheritance is one of the most important features of any object oriented programming language such as Java. This is because it makes easier to build new classes from existing classes without necessarily having to rewrite the same lines of code.