can we create instance for interface in java?

Answer Posted / guru

interface call2
{


void get1();
int a=8;
}


interface call extends call2
{


void get();

}



class interex implements call,call2
{

public void get()
{

System.out.println("hi");

}
public void get1()
{System.out.println("hsfwsi");}
}


class interex1
{
public static void main(String s[])
{
call e=new interex1();



e.get();
e.get1();

System.out.println(e.a);
}
}

second pgm
-----------
interface call2
{


void get1();
int a=8;
}


interface call extends call2
{


void get();

}



class interex implements call,call2
{

public void get()
{

System.out.println("hi");

}
public void get1()
{System.out.println("hsfwsi");}
}


class interex1
{
public static void main(String s[])
{
call e=new interex();



e.get();
e.get1();

System.out.println(e.a);
}
}

Is This Answer Correct ?    14 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you identify if jvm is 32-bit or 64-bit from java program?

540


Can we sort array in java?

531


What is the difference between stringbuffer and stringbuilder?

577


What is a subsequence of a string?

550


Can a class extend more than one class?

618






Can constructor be inherited?

579


What is string and example?

559


Can a final variable be manipulated in java?

539


What is static keyword in java?

555


Write a program to print 15 random numbers using foreach of java 8?

549


Can list have duplicates in java?

523


If two threads have same priority which thread will be executed first ?

846


What is a variable declaration?

531


What is an example of procedure?

518


What is the purpose of stub and skeleton?

549