answersLogoWhite

0


Best Answer

Yes. Java does not support full fledged/proper multiple inheritance. But, whatever partial inheritance that Java supports can be implemented using interfaces

Actually, java does not support multiple inheritance. You can achieve partial multiple inheritance using interfaces but java is not like C or C++ where you can do direct multiple inheritance. However, you can achieve partial multiple inheritance with the help of interfaces.

Ex: public class FerrariF12011 extends Ferrari implements Car, Automobile {…}

And this is under the assumption that Car and Automobile are interfaces.

Here if you see, though you don't inherit concrete code from the Car or the Automobile interface, you do inherit skeleton methods that determine the way your class eventually behaves and hence this can be considered partial Multiple Inheritance.

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Can we implement multiple inheritance in java using package and interface?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is package Explain steps to Create Package?

you intend to create a document using word processor package. explain the steps you will follow and the tools and features provided by the application you will apply


What is the Difference between header file and package?

A package is just a mechanism for grouping objects, it is very similar to grouping items within a folder or directory on a file system. A class is found within a package, but this does not have an impact on the class' behavior (review the "package" access level for a slight exception). An interface, however, is a .java file that is used (implemented) by another class to tell the outside world that it conforms to a certain specification. For example, you might have a "Runnable" interface that has a "run()" method in it, by having a class that is "Runnable" (implements Runnable) anyone using that class knows that it must have a "run()" method defined. This is used when you have several different classes that have the same interface. Interfaces have more in common with abstract classes than they do with packages. An interface, by definition, cannot have any implemented methods; an abstract class, in contrast, can define some methods and leave some methods to be implemented by a subclass. Also, a class can implement many interfaces, but can only extend one (abstract) class. Answer by Sahe Alam Ansari, BCA. Nepal bhairahawa. Email: mrsahealam@gmail.com


How do you write a Java class that implements the collection interface found in the java.util package?

Type in "implements java.util.Collection" after the class name.


How do you add a class or an interface to a package in java?

Well, the process differs whether you are using either an IDE or the command line binaries. If you are using an IDE, then it is most likely that your IDE comes with extensive functionality for both managing and creating packages. Look under the "Packages" menu, or, when you are using Eclipse, just right click on the package name in the Package Explorer window and a flood of possibilities will come right up. If you are using the command line binaries, then there are 2 steps to putting your classes in a package. First, you have to put your class or interface in the appropriate folder structure. For example, if you are using the package com.foo.bar.beebop, then you have to put your class in a folder named beebop, which is in a folder named bar, which is in a folder named foo, which is in a folder named com, which is in your class directory. Then, you have to add a package statement, which is only allowed to be at the top of your class file. For example, if you're using the package com.foo.bar.beebop, then put the following statement at the top of your class: package com.foo.bar.beebop; Then skip a line, then come your import statements (if you have any), then stick in another line (if you have inport statements), then your class. Enjoy!


What is awt in java?

java.awt is a standard package of Java. It is a GUI(Graphical User Interface) package, which has classes in it such as Frame, Panel, and Button. Most of the package was later replaced with the javax.swing package, which has most of the same classes, only with a J prepended to them (JFrame, JPanel, JButton). However the java.awt package still includes some event handlers that are considered standard in java (java.awt.event).

Related questions

What is the package and interfaces?

Package:- package is collection of related classes and interfaces which can be import in our program. There are different built in packages available in java.Package provide us a facility to create user define packages. Interfaces:- Interface is just like abstract class but the difference is that we can implements any no of interfaces in a single class .It is an alternative solution for multiple inheritance which is not available in java. Once we have implement the interface we can define methods of that interface in our class.


How do we save packages and interface in java?

with the package name syntax: <package name> with the interface name.


What is a vhdl package?

A package is a collection of types, constants, subprograms etc.These are usually intended to implement some particular service or to isolate a group of related items.In particular, the details of constant values and subprogram bodies can be hidden from users of a package, with only their interfaces made visible.A package may be split into two parts:a package declaration, which defines its interface, anda package body, which defines the deferred details.The body part may be omitted if there are no deferred details.The syntax of a package declaration is as follows:package_declaration ::=package identifier ispackage_declarative_partend [ package_simple_name ] ;


What is package Explain steps to Create Package?

you intend to create a document using word processor package. explain the steps you will follow and the tools and features provided by the application you will apply


What is the Difference between header file and package?

A package is just a mechanism for grouping objects, it is very similar to grouping items within a folder or directory on a file system. A class is found within a package, but this does not have an impact on the class' behavior (review the "package" access level for a slight exception). An interface, however, is a .java file that is used (implemented) by another class to tell the outside world that it conforms to a certain specification. For example, you might have a "Runnable" interface that has a "run()" method in it, by having a class that is "Runnable" (implements Runnable) anyone using that class knows that it must have a "run()" method defined. This is used when you have several different classes that have the same interface. Interfaces have more in common with abstract classes than they do with packages. An interface, by definition, cannot have any implemented methods; an abstract class, in contrast, can define some methods and leave some methods to be implemented by a subclass. Also, a class can implement many interfaces, but can only extend one (abstract) class. Answer by Sahe Alam Ansari, BCA. Nepal bhairahawa. Email: mrsahealam@gmail.com


What is treemap in java?

A TreeMap is a class in the java.util package that implements the Map data structure - that is, it associates certain keys with their respective values. It stores the key-value pairs in a tree, which means that the keys must implement the Comparable interface. The put() and get() methods are used to manipulate the elements in the map. HashMap is another class in the java.util package that implements a Map, but it uses hashes to store the key-value pairs.


Outlook Express is GUI or TUI?

Outlook Express, which is part of the Windows Package, is both a graphical user interface(GUI) and text-based user interface(TUI).


How do you write a Java class that implements the collection interface found in the java.util package?

Type in "implements java.util.Collection" after the class name.


Why are Windows XP Themes still being made?

Windows XP themes are still being made due to the number of users still on the interface. Consumers with an older package were rolled onto a new XP interface in 2008.


Why are CPUs called cores?

When CPUs first started coming out, and for many years after, they could only execute one set of instructions at a time. After awhile, interfaces were built to support having multiple CPUs running at the same time to increase the horsepower of a machine. These CPUs had distinct packaging still, but now the computer as a whole could execute a set of instructions per CPU. CPU manufacturers started placing multiple CPUs in one distinct package and also included the interface for the CPUs to talk within this package. So even though you had one product, it could execute multiple instructions at one time. Core is a marketing term to let people know the number of independent sets of instructions that a single CPU package can execute.


Which Spa resort has that best package for multiple day treatments?

There are multiple resorts that have good discounts on multiple day treatments. The best way is to compare resorts online or by searching for coupons to results.


What is the yum meanning in red hat?

yum means - YELLOWDOG UPDATER MODIFIER.It is a software package manager that install, removes and update packages on RPM based system.the advantage of using yum is - During installation of Packages, it also installs the dependent packages needed with them.Other are :-Support for multiple repositoriesSimple configurationDependency calculationFast operationRPM-consistent behaviorPackage group support, including multiple-repository groupsSimple interface