answersLogoWhite

0

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...

User Avatar

Wiki User

16y ago

What else can I help you with?

Related Questions

How do you prevent inheritance in java?

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.


How do you prevent class extending in java?

Declare the class as final. final class A{ ... }


How do you prevent extending a class in java?

You can declare a class as "final".


What does java not support?

Java does not support multiple inheritance.......


Which is the mechanism of reusing the existing class without modification?

we can use classes in java...by inheritance concept...we can reuse without modification


What is ambiguity in multiple inheritance?

Java does not support multiple inheritance


How can you write multiple inheritance program in java?

Java does not support direct multiple inheritance. You can implement partial multiple inheritance using interfaces. ex: public class ExMultInherit implements interface1, interface2, interface 3 { ... .... ...... }


What kind of inheritance is not allowed in java?

Java does not allow the multiple inheritance of concrete classes, though it does allow a "hybrid" inheritance of one concrete class and multiple interfaces.


What is problem in multiple inheritance?

Java does not support direct multiple Inheritance. Harder to implement, not every language support it: C++ does, Java does not.


Give the structure of multiple inheritance?

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.


What is public inheritance 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


What is the importance of inheritance in java programming?

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.