answersLogoWhite

0


Best Answer

Import brings all the stuff of a file/API where you have imported it and increases redundancy while inheritance reduces redundancy, increase efficiency of code & makes it manageable. And most important point to remember is that, inheritance is a design followed over the whole project to archive polymorphism.

Thanks & Regards:

Vaibhav Singh

User Avatar

Wiki User

12y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

Extending a class means creating a subclass, also known as a derived class, or a child class, from a class.

Importing a class simply means making the class available, so you can create objects based on the class.

Extending a class means creating a subclass, also known as a derived class, or a child class, from a class.

Importing a class simply means making the class available, so you can create objects based on the class.

Extending a class means creating a subclass, also known as a derived class, or a child class, from a class.

Importing a class simply means making the class available, so you can create objects based on the class.

Extending a class means creating a subclass, also known as a derived class, or a child class, from a class.

Importing a class simply means making the class available, so you can create objects based on the class.

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

All a "import" statement does is make it so that you only have to type the class name, and not the package name each time you use it. Extends means that your class is actually a instance of that class. Your class would behave as if it were one of the class you are extending from, except it may implement functionality differently, and add extra functionality.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

A derived class automatically inherits all the public and protected members of its base class, which it can override if necessary. By percolating all common functionality up to the base class, the derived class can inherit that common functionality, augment it and make it more refined, without having to rewrite the common code itself. As a result, consumers of the base class can use the common interface, irrespective of the classes that are derived from it. They will all do what is expected of them by their inherited interfaces.

Delegation is where one class method calls a method in another class that is better able to deal with the call. To use an analogy, a telephone exchange is not concerned with the individual ringtone produced by each of the telephones that are connected to it. It only needs to know how to make a phone ring, and delegate the work of actually ringing to the telephone itself. In other words, it only needs to know what it does, not how it actually does it.

Similarly with classes that contain other classes. The containing class doesn't require any intimate knowledge of all the classes it contains. By delegating calls to the contained classes, the containing class essentially gets all the credit, but does none of the actual work.

Delegation can also be applied to inheritance. A derived object may override a base class function in order to refine it, but is still free to delegate the call to the base class rather than duplicate the code it contains. Again, the derived class is not concerned with the inner workings of its base class. It is only concerned with what it does, never how it does it (this is otherwise known as encapsulation and data-hiding).

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

Extending a class means creating a subclass, also known as a derived class, or a child class, from a class.

Importing a class simply means making the class available, so you can create objects based on the class.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Difference between import and extends in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

List two methods to import java packages?

Java packages can be imported using the import key word in java. There are two ways of importing java programs. 1. you can import the class along with the fully classified class name. Ex: import java.lang.String; 2. you can import all classes in a package using the star symbol. Ex: import java.lang.*;


What is the main difference between UNIX and JAVA?

Unix is an operating system, Java is a language.


Difference between recordset and resultset in java?

Rowset


WAP to show the difference between a variable and static variable?

difference between constant and static variables in java


How do you import an entire package of class in java?

import package_name.*;where package_name is your package name.by using this syntax you can import an entire package.

Related questions

What is difference between java 2 and java 5?

They are different versions. Java 5 is newer than Java 2. Think of it like the difference between the Playstation 1 and the Playstation 3.


How do you import others codes in java?

using servlets, php, and database we can connect import codes into java


What is the difference between Java bean and bean?

JAVA beans and coffee beans are two very different things . JAVA beans are used to generate getters and setters. while coffee beans are use to make coffee.


List two methods to import java packages?

Java packages can be imported using the import key word in java. There are two ways of importing java programs. 1. you can import the class along with the fully classified class name. Ex: import java.lang.String; 2. you can import all classes in a package using the star symbol. Ex: import java.lang.*;


Major difference between c and java?

Java is object oriented, C is not...


What is the difference between connectivity in java?

kamina


What is difference between connectivity in java?

kamina


What is the main difference between UNIX and JAVA?

Unix is an operating system, Java is a language.


Difference between recordset and resultset in java?

Rowset


What is the difference between JAD and JAR?

JAD-Java Application Description JAR-Java archive


Import a package second time in Java?

You can import a package as many times as you want in Java. The compiler will just ignore any duplicates.


What is the difference between java and object oriented programming?

java is a programming language/platform that embodies object oriented programming concepts. The question of what is the difference is like asking what is the difference between cars and a Volvo.