Hello Ranchers,
Need your help.
I am bit confused between abstract and interface.
Abstract class defines and implements methods and cannot be instantiated.
Interface only dfines methods but can't implement those methods itself.
What this means??
For eg:
Abstract class
public abstract class A
{
public abstract void set();
public abstract
String get();
}
public class B extends A
{
public abstract void set()
{
Strin name ="Agra"
}
public abstract String get()
{
return name();
}
public class demo
{
public static void main(String []args)
{
B b1= new B();
b.set();
String d = b.get();
System.out.print("d);
}
}
//Interface
interface A
{
public void set();
public String get();
}
class demo implements A
{
public void set()
{
String f ="Juhu"
}
public string get()
{
return f();
}
public class
test {
public static void main(String []a)
{
demo d1 =new d1();
d1.set();
String h = d1.get();
System.out.println(h);
}
}
My question is that in above examples we are defining and also implementing then what is difference between two abstract and interface?
Please help me out...
Thanks in advance
