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
What are virtual methods?
 Question Submitted By :: Guest
I also faced this Question!!     Rank Answer Posted By  
 
  Re: What are virtual methods?
Answer
# 1
in java all function are virtual.only the function marked 
with the final is not virtual.
means to say that if there is any method in super class and 
you implemented this method in subclasses too.
then you can invoke on  any subcalsses instances refer to 
as a superclasses.and the method behaviour will change 
according to subcallses instances .
class Amit
{
public void sleep()
{
System.out.println("amit slleping");
}
public static void main(String []args)
{
Amit a = new Amit();
a.sleep();
a = new Subclass1();
a.sleep();
a= new Subclass2();
a.sleep();
}
}

class Subclass1 extends Amit
{
public void sleep()
{
Sysetm.out.println("subclass sleeping");
}
}

class Subclass1 extends Amit
{
public void sleep()
{
System.out.println("subclass 2 sleeping");
}
}
so the output will be 
amit sleeping
Subclass1 sleeping
Subclass2 sleeping

so the eat function behave virtualy for the differnt 
instance .so this is called the virtual function .so don't 
worry every function in java are virtual not the final 
function.
 
Is This Answer Correct ?    0 Yes 0 No
Amit Singh
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
What is the USE of Null interfaces ??...if thers nothing inside these interfaces how are they used and WHy are they used ???? No 1 has given a proper description yet  1
What is the top class of AWT event hierarchy?  5
There are 2 methods in a class. Both have the same method signature except for return types. Is this overloading or overriding or what is it? KPIT7
In what circumstances, compiler will supply a default constructor for a class?  4
what is bytecode? watz the difference between machine code and bytecode? Oracle4
why abstract class will have a constructor?  3
Can a double value be cast to a byte?  3
What is a deadlock ?  5
How the elements are organized in GridLayout?  1
Can we override static methods? Bally-Technologies15
Which class has no duplicate elements?  8
what is the diff between Servletcontext and servletconfig?  5
explain the life cycle of thread? CTS5
how many types of cloning? Mobily1
What is means by DLL file means ? What is the use of DLL file? What are the contents of DLL file?  2
What is the immediate superclass of Menu?  1
What is the difference between overloading and overriding a function? Infosys7
How do you compare two strings? any predefined method for this?  2
Explain different ways of passing arguments to sub-routine?  1
What is Three tier architecture. Can anyone explain with a Ordinary web application Project? (JSP,Servlets,JAVA,DAO) ? TCS1
 
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