How will you define an interface? ,Java, C ,C++, ASP, C# ,Struts ,Questions & Answer, Struts2, Ajax, Hibernate, Swing ,JSP , Servlet, J2EE ,Core Java ,Stping, VC++, HTML, DHTML, JAVASCRIPT, VB ,CSS, interview ,questions, and answers, for,experienced, and fresher
How will you define an interface?

The following syntax is used to define the interface :
 accessModifier interface InterfaceName{
   dataType var1;
   dataType var2;
   void method1();
   void method2();

Here accessModifier may be default or public.
Interface may contain constant variables. These variables are implicitly public static final, you don\'t have to type it explicitly.
Interface can have only public abstract methods, you dont have to type public abstract modifiers explicitly.

More interview questions and answers
What is the difference between RandomAccessFile and File?
What is the difference among JVM Spec, JVM Implementation, JVM Runtime ?
What is the difference between Hashtable and HashMap ?
Why java is said to be pass-by-value ?
What do you mean by immutable ? How to create an immutable object ?
What is a weak reference ?
What is object cloning?
What is object pooling?
What is the disadvantage of garbage collection?
What are tag interfaces?
What are the restrictions placed on static method ?
What is JIT?
What is the Locale class?
What is the difference between URL and URLConnection?
What are the two important TCP Socket classes?
Strings are immutable. But String s=\"Hello\"; String s1=s+\"World\" returns HelloWorld how ?
What is classpath?
What is path?
What is java collections?
Can we compile a java program without main?
What is static initializer block? What is its use?
How does a try statement determine which catch clause should be used to handle an exception?
If a class doesn\'t have any constructors, what will happen?
What will happen if a thread cannot acquire a lock on an object?
What will happen if you are invoking a thread's interrupt method while the thread is waiting or sleeping?
What is coupling?
How will you define an interface?
How will you define an abstract class?
What is a JVM heap?
What is daemon thread?
What is a green thread?
What is volatile variable?
What is diamond problem?
How many JVM's we can run in a system?
Why ArrayList is faster than Vector?
What is the security mechnaism used in java?
What is phantom memory?
What is reflection?
What are the differences between JIT and HotSpot?
How would you implement a thread pool?
What is the difference between throw and throws clause?
What is the difference between Comparable and Comparator ?
What is the difference between List, Set and Map?
What is the difference between Exception and Error ?
What is meant by Open Source ?
How do you send data from an applet to Servlet ? What are the steps involved in it ?
What are the different inner classes types?
What is Nested top-level classes?
What is Member classes?
Can a top level class be private or protected?
How will you invoke any external process in Java?
What is composition?
What is aggregation?
What are the methods in Object?
What is the relationship between synchronized and volatile keyword?
What factors are used to decide using synchronized or volatile?
What are the drawbacks of inheritance?
What are the restrictions placed on the values of each case of a switch statement?
If aaaa is an array then why aaaa.length why not aaaa.length()?
What is dynamic typing?
What is static typig?
What is HashMap and Map?
What is an Object and how do you allocate memory to it?
What is UNICODE?
What is a stream and what are the types of Streams and classes of the Streams?
What is the difference between TCP/IP and UDP?
What is Inter-Thread communication?.
What is a thread group?
Why is UTFDataFormatException thrown by DataOutputStream.writeUTF() when serializing a String?
Why is OutOfMemoryError thrown after writing a large number of objects into an ObjectOutputStream?
How can I get the serialVersionUID of a class?
main() { int c[ ]={2.8,3.4,4,6.7,5}; int j,*p=c,*q=c; for(j=0;j<5;j++) { printf(" %d ",*c); ++q; } for(j=0;j<5;j++){ printf(" %d ",*p); ++p; } }
main() { extern int i; i=20; printf("%d",i); }
main() { int i=-1,j=-1,k=0,l=2,a; a=i++&&j++&&k++||l++; printf("%d %d %d %d %d",i,j,k,l,a); }
main() { int c=- -2; printf("c=%d",c); }
#define int char main() { int i=65; printf("sizeof(i)=%d",sizeof(i)); }
main() { int a=10; a=!a>14; Printf ("a=%d",a); }
#include main() { char s[]={'a','b','c','\n','c','\0'}; char *p,*str,*str1; p=&s[3]; str=p; str1=s; printf("%d",++*p + ++*str1-32); }
#include main() { int a[2][2][2] = {{10,2,3,4},{5,6,7,8}}; int *p,*q; p=&a[2][2][2]; *q=***a; printf("%d----%d",*p,*q); }
#include main() { struct xx { int x=3; char name[]="vivek"; }; struct xx *s; printf("%d",s->x); printf("%s",s->name); }
#include main() { struct xx { int x; struct yy { char s; struct xx *p; }; struct yy *q; }; }
main() { printf("\nab"); printf("\bsi"); printf("\rha"); }
main() { int i=5; printf("%d%d%d%d%d%d",i++,i--,++i,--i,i); }
#define square(x) x*x main() { int i; i = 125/square(5); printf("%d",i); }
#define square(x) x*x main() { int i; i = 125/square(5); printf("%d",i); }
main() { char *p="hey friends",*p1; p1=p; while(*p!='\0') ++*p++; printf("%s %s",p,p1); }
main() { char *p="hai friends",*p1; p1=p; while(*p!='\0') ++*p++; printf("%s %s",p,p1); }
#include #define i 10 main() { #define i 50 printf("%d",i); }
#define clrscr() 100 main() { clrscr(); printf("%d\n",clrscr()); }
main() { printf("%p",main); }
main() { clrscr(); } clrscr();
enum colors {BLACK,BLUE,GREEN} main() { printf("%d..%d..%d",BLACK,BLUE,GREEN); return(1); }
void main() { char far *farther,*farthest; printf("%d..%d",sizeof(farther),sizeof(farthest)); }
main() { int i=400,j=300; printf("%d..%d"); }
main() { char *p; p="java"; printf("%c\n",*&*p); }
main() { int i=1; while (i<=5) { printf("%d",i); if (i>2) goto here; i++; } } fun() { here: printf("PP"); }
main() { static char names[5][20]={"pascal","ada","cobol","fortran","perl"}; int i; char *t; t=names[3]; names[3]=names[4]; names[4]=t; for (i=0;i<=4;i++) printf("%s
void main() { int a=5; printf("%d",a++ + ++a); }
void main() { int i=5; printf("%d",i+++++i); }
#include main() { int i=1,j=2; switch(i) { case 1: printf("GOOD"); break; case j: printf("BAD"); break; } }