Describe interfaces in java langauge, JAVA Programming

Assignment Help:

Describe Interfaces in java langauge?

Interfaces are the further level of abstraction. An interface is like a class along with nothing but abstract methods and final, static fields. All methods and fields of an interface must be public.

Therefore, unlike a class, an interface can be added to a class which is already a subclass of another class. In addition an interface can apply to members of several different classes. For example you can define an Import interface with the single techniques calculateTariff().

public interface Import {

public double calculateTariff();

}

You might need to use this interface on several different classes, cars between them but also for clothes, food, electronics and more. It would be inconvenient to form all these objects derive from a single class. Additionally, each different kinds of item is likely to have a different means of calculating the tariff. Thus you define an Import interface and declare in which each class implements Import.

The syntax is easy. Import is declared public so in which it can be accessed from any class. It is also probable to declare that an interface is protected so that it can only be implemented by classes in a particular package. However this is extremely unusual. Almost all interfaces will be public. No interface may be private because the whole purpose of an Interface is to be inherited through other classes.

The interface keyword takes the place of the class keyword. Line 3 looks such as a classic method definition. It's public (as it must be). It's abstract, also as it must be. And it returns a double. The method's name is calculateTariff() and it takes no arguments. The difference among this method and a method in a class is that there is no method body. That remains to be created in each class in which implements the interface.

You can declare several different methods in an interface. These methods may be overloaded. An interface can also have fields, but if so they must be final and static (in other words constants).


Related Discussions:- Describe interfaces in java langauge

JAVA Fundamentals, 15. Energy Drink Consumption A soft drink company recent...

15. Energy Drink Consumption A soft drink company recently surveyed 12,467 of its customers and found that approximately 14 percent of those surveyed purchase one or more energy dr

How can you performance tune your database?, 1. De normalizes your tables w...

1. De normalizes your tables where required. 2. Proper use of index columns: An index based on numeric parts is more efficient than an index based on character columns. 3. Re

Explain the ? operator in java, Explain The ?  operator in Java ? The...

Explain The ?  operator in Java ? The value of a variable frequent depends on whether a particular boolean expression is or is not true and on nothing else. For example one ge

Web application using javascript-xml and css, Journal of how you came to AU...

Journal of how you came to AUB Write a web application using JavaScript, XML and CSS that contains a journal of major events and places on your journey to Bond University. The

Problem, #questionSmugglers are becoming very smart day by day. Now they ha...

#questionSmugglers are becoming very smart day by day. Now they have developed a new technique of sending their messages from one smuggler to another. In their new technology, they

What is best algorithm, What is best algorithm? Greedy algorithm is the...

What is best algorithm? Greedy algorithm is the best algorithm as it is n algorithm in which always takes the best immediate, or local solution although searching an answer.

Is jsp technology extensible?, YES. JSP technology is extensible by the dev...

YES. JSP technology is extensible by the development of custom actions, or tags, which are encapsulated in tag libraries. #question..

What are the different modules in spring framework, Different modules in sp...

Different modules in spring framework are:- a)  The Core container module b)  AOP module (Aspect Oriented Programming) c)  Application context module d) JDBC abstractio

Test driven development (tdd)? , Test Driven Development (TDD) TDD pro...

Test Driven Development (TDD) TDD process gives your confidence in the delivered code for the following things. 1. TDD can remove duplication of code and also disciplines t

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd