ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   SiteMap shows list of All Categories in this site.
Google
 
Categories  >>  Software  >>  Core Java  >>  Java J2EE  >>  Java Related
 
 


 

 
 Core Java interview questions  Core Java Interview Questions
 Advanced Java interview questions  Advanced Java Interview Questions
 Swing interview questions  Swing Interview Questions
 EJB interview questions  EJB Interview Questions
 Servlets interview questions  Servlets Interview Questions
 Struts interview questions  Struts Interview Questions
 JDBC interview questions  JDBC Interview Questions
 JMS interview questions  JMS Interview Questions
 SunOne interview questions  SunOne Interview Questions
 J2EE interview questions  J2EE Interview Questions
 Weblogic interview questions  Weblogic Interview Questions
 Websphere interview questions  Websphere Interview Questions
 Java Networking interview questions  Java Networking Interview Questions
 Java J2EE AllOther interview questions  Java J2EE AllOther Interview Questions
Question
diff between abstract methods and interfaces with programing
(code) example?
 Question Submitted By :: Chandan61
I also faced this Question!!     Rank Answer Posted By  
 
  Re: diff between abstract methods and interfaces with programing (code) example?
Answer
# 1
an abstract class contains the concrete methods as well 
abstract methods. It may instance variables and static 
final variables
an interface contains only abstract methods. all the 
variables are by default static and final.
an abstract class contains constructor where as an 
interface does not have constructors...
 
Is This Answer Correct ?    0 Yes 0 No
Naresh P
 
  Re: diff between abstract methods and interfaces with programing (code) example?
Answer
# 2
abstract class A
{
protected abstract void show();
}

public class xx extends A
{
protected void show()
{
System.out.println("karthik ok");

}

static void main(String aa[])
{
xx ob=new xx();
ob.show();
}
}


But in Interface


interface A
{
protected abstract void show();
}



public class xx implements A
{
protected void show()
{
System.out.println("karthik ok");

}

static void main(String aa[])
{
xx ob=new xx();
ob.show();
}
}

modifier protected not allowed here
protected abstract void show(); in Interface
Because Default public method


But in Abstract class we can have protected


interface A
{
int x;//Error we should need initial value
}
 
Is This Answer Correct ?    1 Yes 0 No
Karthik
 
 
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
when we write class.forName("any one class"); what happens actually?what it will return?explain stepwise?  4
What is Transient and volatile iFlex9
Can u overload main()method.Give with example. IBM2
how can you retrive information from database by using hashmap/arraylist ,plz explain with example briefly? Satyam1
What are Encapsulation, Polymorphism and Inheritance?  2
What is the smallest package in Java API?  4
What is a compilation unit?  2
what is Hashmap & Hashtable wirh example? Saksoft4
can we have virtual functions in java? Wipro7
Explain the difference between the Boolean & operator and the && operator?  1
Explain difference between final, finally and finalize?  2
when i write string s1="java"; in one program(application) and string s2="java"; in another application on the same jvm will both objects s2,s2 will refer to same memory location where "java" is stored in string pool.  2
what is meant by serialization?  6
how can u create the object with out new operator  2
What are null interfaces in JAVA ? and give me some examples?  3
can u give one sinario when you use Abstract Class and When you use Interface. ITC-Infotech5
What is the exact difference in between Unicast and Multicast object ? Accenture1
what is difference between type 4 driver and type 1 driver? CMC2
Explain about GridBag Layout?  1
what is the purpose of method overriding in java where v r completely re-defining a inherited method instead y can't v create a new method and define.If the question is very silly plz excuse me and do reply.Thank U!  5
 
For more Core Java Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com