Skip to main content

Interfaces

Java Programming


Interfaces

The interface keyword takes the abstract concept one step further. You could think of it as a “pure” abstract class. It allows the creator to establish the form for a class: method names, argument lists and return types, but no method bodies. An interface can also contain data members of primitive types, but these are implicitly static and final. An interface provides only a form, but no implementation.


 An interface says:  
“This is what all classes that implement this particular interface will look like.” Thus, any code that uses a particular interface knows what methods might be called for that interface, and that’s all. So the interface is used to establish a “protocol” between classes.


The syntax for defining an interface is similar to creating a new class:  


interface <InterfaceName>
 {    
     // constant declarations, if any 
     
     static final <data type> <variable name>  =  <value>;  
   
   // method signatures
   
     <return type> <methodName>(<parameter list>);  
}


watch me on Instagram

https://www.instagram.com/abhishek_av1/




Comments

Popular posts from this blog

Byte Code:

Java Programming Byte Code: It is the unique characteristic property of the Java programming language. It is something like a normal text file. Therefore, it cannot be affected by virus. It is an intermediate between a human readable source and machine readable source. Byte codes are plate form independent. Therefore, JVM is plate form dependent to make Java programming plate form indepdent.  

Difference between Class and Interface

Java Programming   *Difference between Class and Interface                                                  Class 1.  The members of a class can be constant or variables.  2. The class definition can contain code for each of its methods. That is, the methods can be    abstract or non-abstract. 3. It can be instantiated by declaring objects. 4. It can use various access specifier like public,private or protected.                                                Interface     1. The members of an interface are always declared as constant, i.e. their values are final.  2. The methods in an interface are abstract in nature, i.e., there is no code associated with  ...

OPERATING SYSTEM

1.  The term 'operating system'   means: a)  the way a computer operator   works. b)  conversion of high level languages into machine   code. c)  a set of programs which controls computer   working. d)  none of the   above. 2.  What is the name of the operating system that reads and reacts in terms of actual   time: a)   Batch   system b) Time sharing system c) Real   time   system d) all of the above. 3.  The primary job of the operating system of a computer is   to: a)   command   resources b) manage   resources c) be   user friendly d) only one of the   above. 4.  Multiprogramming   systems: a) are easier to develop than single programming systems. b) execute more jobs in same time period. c) are used only on large   mainframe   computers. d) all of the above 5.  Which of the following is not an a...