Home Tutorialhelp Comment Question: What is the difference between the insta

 
 

Comment

gowreesan
Question: What is the difference between the insta,
February 14, 2007 at 11:27 AM

Question: What is the difference between the instanceof and getclass, these two are same or not ?
Answer: instanceof is a operator, not a function while getClass is a method of java.lang.Object class. Consider a condition where we use
if(o.getClass().getName().equals("java.lang.Math")){ }
This method only checks if the classname we have passed is equal to java.lang.Math. The class java.lang.Math is loaded by the bootstrap ClassLoader. This class is an abstract class.This class loader is responsible for loading classes. Every Class object contains a reference to the ClassLoader that defines. getClass() method returns the runtime class of an object. It fetches the java instance of the given fully qualified type name. The code we have written is not necessary, because we should not compare getClass.getName(). The reason behind it is that if the two different class loaders load the same class but for the JVM, it will consider both classes as different classes so, we can't compare their names. It can only gives the implementing class but can't compare a interface, but instanceof operator can.
The instanceof operator compares an object to a specified type. We can use it to test if an object is an instance of a class, an instance of a subclass, or an instance of a class that implements a particular interface. We should try to use instanceof operator in place of getClass() method. Remember instanceof opeator and getClass are not same. Try this example, it will help you to better understand the difference between the two.
Interface one{
}

View All Comments | View Tutorial
Advertisement
Related Tutorial and Articles
Java Beginners

CoreJava
CoreJava  Sir, What is the difference between pass by value and pass by reference. can u give an example 

Programming Tutorials

Corejava Interview,Corejava questions,Corejava Interview Questions,Corejava
is a path name under that directory.     Q 4. What's the difference between a data store and a database ? Ans : Generally the term data store is used... a date with slashes.   Q 11. How can I get the difference between two dates 

SQL Question

difference
difference  what's the difference between mysql and sql 

JDBC Questions

difference
difference  difference between hashtable and hashtree 

Java Beginners

Difference
Difference  What Is the difference between JDK & SDK 

Java Interview Questions

difference between == and === operators?
difference between == and === operators?  Is (====) operator available in java or not? difference between 

Java Server Faces Questions

Difference between struts and JSF
Difference between struts and JSF  What is the difference between struts and JSF 

Struts Questions

difference between ForwardAction and IncludeAction
difference between ForwardAction and IncludeAction  What is the difference between ForwardAction and IncludeAction 

JavaScript Questions

difference between SessionState and ViewState
difference between SessionState and ViewState  What is the difference between SessionState and ViewState 

Struts Questions

Difference between DispatchAction and LookupDispatchAction
Difference between DispatchAction and LookupDispatchAction  What is the Difference between DispatchAction and LookupDispatchAction 

Programming Tutorials

Corejava Interview,Corejava questions,Corejava Interview Questions,Corejava
;     Q 3 : What is dynamic method dispatch ?  Ans...;   Q 5 : What if two interface methods clash in implementation ? ... in not true.     Q 9 : What is a marker interface ?  Ans : In java 

Programming Tutorials

Corejava Interview,Corejava questions,Corejava Interview Questions,Corejava
;} Interfaces Vs Abstract classes Few of the differences between...;   Q 2. What is hashcode? When is hashCode() used ? Ans : .... In such cases, what we do is to just configuring name of the required class 

JDBC Questions

difference
difference    what is the difference between the JDBC-ODBC bridge, the Native-API-Partly-Java driver, and the JDBC-Net-All-Java Driver is the placement of the database access libraries   Please visit the following link 

Java Beginners

difference
difference  difference between thread and process in java   Difference between Process and Thread: 1)Process is a program under execution whereas Thread is a part of program. 2)Process are heavy weight programs which 

Java Beginners

difference
difference  difference between Method Overloading and method Overriding   Difference between Method Overloading and Method Overriding: Overriding is the concept of having functions of same name and signature 

Java Beginners

What is the difference between the >> and >>> operators?
What is the difference between the >> and >>> operators?   hi, What is the difference between the >> and >>> operators? Thanks 

Mobile Applications Questions

Difference between 3d and 4d
Difference between 3d and 4d  what is the difference between 3d and 4d 

SQL Question

difference between varchar & varchar2?
difference between varchar & varchar2?  What is the difference between varchar & varchar2 

Java Interview Questions

Difference between Timer and Thread?
Difference between Timer and Thread?  Can anyone tell me about the difference between Timer and Thread, Why we need to have Timer in case we have Thread implimentation startegy in Java 

SQL Question

Difference between Mysql and SQL
Difference between Mysql and SQL  hello, What is the difference between Mysql and SQL??   hii, SQL is structural quary language but mysql is database package 

Java Beginners

difference between lock and synchronization
difference between lock and synchronization  Hi, I am new in java please anyone tell me difference between lock and synchronization in java. its urgent. Thank in advance   Please visit the following link: Lock 

JSP Interview Questions

Difference between JSP and Servlets
Difference between JSP and Servlets  What is the difference between JSP and Servlets ?   JSP is used mainly for presentation only. A JSP can only be HttpServlet that means the only supported protocol in JSP is HTTP 

Java Beginners

Difference between SCJP Exams
Difference between SCJP Exams  What is the differences between SCJP 5 (310 - 055) exam and SCJP 6 (310 - 065) exam??? Thank You In Adv 

JSP Interview Questions

Difference between request.getRequestDispatcher() and context.getRequestDispatcher()
Difference between request.getRequestDispatcher() and context.getRequestDispatcher()  What is the difference in using request.getRequestDispatcher() and context.getRequestDispatcher()?   request.getRequestDispatcher 

SQL Question

Difference between translate and replace
Difference between translate and replace   hiii, What is the difference between translate and replace?   hello, Replace replace every instence of character with character sting by the given charator of string 

Servlet Interview Questions

Difference between ServletContext and ServletConfig
Difference between ServletContext and ServletConfig   What is the difference between ServletContext and ServletConfig?   ServletContext :Defines a set of methods that a servlet uses to communicate with its servlet 

JSP Interview Questions

Difference between forward and sendRedirect
Difference between forward and sendRedirect  What's the difference between forward and sendRedirect?   RequestDispatcher.forward() and HttpServletResponse.sendRedirect() are the two methods available for URL redirecting 

JSP Interview Questions

Difference between GET and POST
Difference between GET and POST   Difference between GET and POST ?   The difference between a GET and a POST is the way data is transferred to a servlet. With a GET, the URL will show each name/value pair on the query 

Java Beginners

what is the difference between extends and implements
what is the difference between extends and implements  difference between extends and implements 

Java Interview Questions

what is the difference between extends and implements
what is the difference between extends and implements  difference between extends and implements 

Swing AWT

difference between applet and swings
difference between applet and swings  what are the major difference between swing and applets   Hello Friend, Differences: 1) AWT stands... this feature is not supported by AWT. Thanks   Hi Friend, Difference 

Java Beginners

Difference between http and https
Difference between http and https  Difference b/w HTTP and HTTPS please provide answer in tabular form.   Hi Friend, Differences: 1)HTTP is hyper text transfer protocol which is responsible for transmitting 

Java Magazine Questions

Difference between error and exception ????????
Difference between error and exception ?  Can we handle a error in java if yes than give an code of an example? Difference between error and exception handling.......   Exceptions are things you can create/throw 

PHP Questions

difference between $message and $$message
difference between $message and $$message  What is the difference between $message and $$message?   Hi friends, $message is a simple variable whereas $$message is a reference variable. Example: $name = 'Bharat 

Framework Questions

Difference between Struts and Spring
Difference between Struts and Spring  What are the difference between Struts and Spring?   Hi Friend, Differences: 1)Struts is a web framework while Spring is not. 2)Spring is a Layered Architecture while Struts 

Hibernate Questions

What is the difference between hibernate and spring
What is the difference between hibernate and spring  Hi, What is the difference between hibernate and spring. Thanks 

Java Interview Questions

difference between hashcode,reference in java
difference between hashcode,reference in java  difference between hashcode,reference in java 

Java Beginners

what is the difference between pop and oop
what is the difference between pop and oop  what is the difference between pop and oop 

Java Interview Questions

what is the Difference between weblogic and jboss?
what is the Difference between weblogic and jboss?  what is the Difference between weblogic and jboss 

PHP Questions

What is the difference between $message and $$message?
What is the difference between $message and $$message?  What is the difference between $message and $$message 

JSP Interview Questions

difference between <%@ include ...> and <jsp:include>
difference between <%@ include ...> and   What is the difference between <%@ include ...> (directive include) and <jsp:include> 

XML Questions

Difference between XML and HTML - XML
Difference between XML and HTML  What is the basic Difference between XML and HTML 

SQL Question

What is difference between a PROCEDURE & FUNCTION ?
What is difference between a PROCEDURE & FUNCTION ?  What is difference between a PROCEDURE & FUNCTION 

PHP Questions

What is the difference between PHP4 and PHP5?
What is the difference between PHP4 and PHP5?  What is the difference between PHP4 and PHP5 

Java Beginners

What is the difference between a constructor and a method?
What is the difference between a constructor and a method?  Hi, What is the difference between a constructor and a method?   Hi, I have found a good link of Java program related to difference between constructor 

Java Beginners

Difference between jsonstring and json object
Difference between jsonstring and json object  Is There any difference between JsonString and jsonobjectA? if there is any differece could any one explain with example. Thanks venkatesh 

Java Interview Questions

What is difference between the java and javascript?
What is difference between the java and javascript?  What is the difference beteen the java and javascript?   Hello Friend, Read Here Thanks 

SQL Question

Difference between TRUNCATE and DELETE commands
Difference between TRUNCATE and DELETE commands  hii, What is the difference between TRUNCATE and DELETE commands?   hello, TRUNCATE is a DDL command whereas DELETE is a DML command. TRUNCATE is much faster than 

JavaScript Questions

calculate difference between two dates
calculate difference between two dates  hi, I was actually working on to calculate the number of days between two dates of dd/mm/yyyy format... the difference between the two dates 

Java Beginners

difference between prepared statement and statement
difference between prepared statement and statement  i mean in prepared statement we write insert command as INSERT INTO tablename VALUES...(),jtextfield2.getText()); whats the difference between these two and which is more 

Hibernate Questions

Difference between and merge and update in hibernate
Difference between and merge and update in hibernate  What is difference between and merge and update in hibernate?   Use update() if you are sure that the session does not contain an already persistent instance 

Struts Questions

Difference between MVC1 And MVC2 - Struts
Difference between MVC1 And MVC2  HI Friends,Can u Give me difference between mvc1 and mvc2. Thanks Prakash  Hi Friend, Please visit the following link: http://www.roseindia.net/struts/mvc-architecture.shtml 

SQL Question

mysql difference between two numbers
mysql difference between two numbers  How to get total bate difference between two dates for example 1/01/2012 and 1/02/2012 in MYSQL?   ..., '01/02/2012', 103))   DATEDIFF() in MYSQL always returns the difference 

Java Beginners

What is the difference between a JDK and a JVM?
What is the difference between a JDK and a JVM?  Hi, What is the difference between a JDK and a JVM? Thanks,   Hi, JDK is stand... to compile your source files using a JVM. For more difference between JDK and JVM 

Java Interview Questions

corejava - Java Interview Questions
|| year==0 || yearmaxYear){ alert("Please enter a valid 4 digit year between 

Java Beginners

What is difference between Path and Classpath?
What is difference between Path and Classpath?   hi What is difference between Path and Classpath? thanks   Hi, The Path & Classpath are used for operating system level environment variales. We mostly use Path 

Java Beginners

difference between enum and final class?
difference between enum and final class?  what is the difference between enum and final class in java?   The java.lang.Enum is an abstract class, it is the common base class of all Java language enumeration types 

Java Beginners

difference between wite and writeto in java
difference between wite and writeto in java  I am using the stream to write content to the file.I am using write() method but my friend suggest the writeTo() method. I want to know difference between the write() and writeTo 

Servlet Interview Questions

difference between servletconfig and servletcontext in java
difference between servletconfig and servletcontext in java  difference between servletconfig and servletcontext in java   ServletContext ServletContext is implemented by the servlet container for all servlet 

Flex Questions

Difference between httpService and Data Service
Difference between httpService and Data Service  Hi.. Please tell me What is the difference between httpService and Data Service? Thanks  Solution: When we use flex Data Services we have to need 

Java Interview Questions

corejava
corejava  if we declare abstract as final what happen 

Java Beginners

corejava
 

SQL Question

What is difference between TRUNCATE & DELETE
What is difference between TRUNCATE & DELETE   What is difference between TRUNCATE & DELETE?   Hi, The DELETE command is used to remove rows from a table. A WHERE clause can be used to only remove some rows 

Hibernate Questions

Difference between getCurrentSession() and openSession() in Hibernate ?
Difference between getCurrentSession() and openSession() in Hibernate ?  What is difference between getCurrentSession() and openSession() in Hibernate ?   getCurrentSession() : The "current session" refers 

Java Beginners

difference between the obj and reference - Java Beginners
difference between the obj and reference  what is the difference between object and reference ? is there any difference 

Java Interview Questions

What is difference between the java and javascript?
What is difference between the java and javascript?  What is the difference beteen the java and javascript?   Hello Friend, Difference: 1) Java is a Object Oriented programming language developed by Sun Microsystems 

Java Interview Questions

difference between servletconfig and servletcontext in java
difference between servletconfig and servletcontext in java  ServletConfig is implemented by the servlet container to initialize a single servlet using init(). ServletContext is implemented by the servlet container for all 

Java Beginners

Difference between documentation comment and multiline comment in java?
Difference between documentation comment and multiline comment in java?  Difference between documentation comment and multiline comment in java 

Java Beginners

What is the difference between JSF, Servlet and JSP?
What is the difference between JSF, Servlet and JSP?  What is the difference between JSF, Servlet and JSP 

Java Beginners

Difference between declaring variables before or in loop?
Difference between declaring variables before or in loop?  Difference between declaring variables before or in loop 

Spring Framework Questions

What is difference between singleton and prototype bean?
What is difference between singleton and prototype bean?  Hi, What is difference between singleton and prototype bean? Thanks 

Hibernate Questions

What’s the difference between load() and get()?
What?s the difference between load() and get()?   Hi, What?s the difference between load() and get()? thanks 

Java Beginners

what is the difference between distributed application and web application?
what is the difference between distributed application and web application?  what is the difference between distributed application and web application 

Java Interview Questions

DIFFERENCE BETWEEN APPLICATION SERVER AND WEB SERVER
DIFFERENCE BETWEEN APPLICATION SERVER AND WEB SERVER  What is the difference between application server and web server 

JSP Servlet Questions

calculate difference between two time in jsp
calculate difference between two time in jsp  How to calculate difference between two dates 

PHP Questions

What’s the difference between include and require?
What?s the difference between include and require?  What?s the difference between include and require 

PHP Questions

What are the difference between abstract class and interface?
What are the difference between abstract class and interface?  What are the difference between abstract class and interface 

Java Beginners

what is difference between objectan primitive? - Java Beginners
what is difference between objectan primitive?  whatis difference between object and primitive 

PHP Questions

What is the difference between the functions unlink and unset?
What is the difference between the functions unlink and unset?  What is the difference between the functions unlink and unset 

PHP Questions

What is the difference between ereg_replace() and eregi_replace()?
What is the difference between ereg_replace() and eregi_replace()?  What is the difference between eregreplace() and eregireplace 

Java Beginners

Difference between object and instance? - Java Beginners
Difference between object and instance?  What is the difference between object and instance in java 

Servlets-Tutorials

Difference Between Servlet and JSP
Difference Between Servlet and JSP In this section we will describe the Servlet and JSP. We will compare the both technologies. We will discuss the differences between Servlet and JSP. Servlet Servlet is a Java class that is usually 

Spring Framework Questions

What are difference between Bean Factory and Application Context ?
What are difference between Bean Factory and Application Context ?  Hi, What are difference between Bean Factory and Application Context 

Java Beginners

What is the difference between the Boolean & operator and the && operator?
What is the difference between the Boolean & operator and the && operator?   Hello, What is the difference between the Boolean & operator and the && operator? thanks 

Java Interview Questions

what is the difference between productList==null and productList.size()==0
what is the difference between productList==null and productList.size()==0  what is the difference between productList==null and productList.size()==0? here productList is of type LIST 

Servlet Interview Questions

difference between init() & init(ServletConfig config)?
difference between init() & init(ServletConfig config)?  I want to know the difference between init() and init(ServletConfig config) methods in GenericServlet 

Struts Questions

difference between session scope and request scope
difference between session scope and request scope   What is the difference between session scope and request scope when saving formbean 

Java Beginners

difference between java5 and java6 - Java Beginners
difference between java5 and java6  Hi, What is difference between java5 and java6 Please let me know quickly 

Mobile Applications Questions

difference between touch screen and non touch screen
difference between touch screen and non touch screen  code wise ,what is a difference between touch screen and non touch screen in J2ME 

Mobile Applications Questions

difference between touch screen and non touch screen
difference between touch screen and non touch screen  what is a difference between touch screen and non touch screen in J2ME (code wise 

JSP Servlet Questions

RequestDispatcher object, difference between include( ) and forward( ) method.
RequestDispatcher object, difference between include( ) and forward( ) method.  The RequestDispatcher object has two methods, include( ) and forward( ). What is the difference 

Management

difference between business analyst and project manager
difference between business analyst and project manager  What is the difference between a business analyst and a project manager? How can a Project Management Certificate prove helpful for the Business analyst 

SQL Question

What is the difference between IN and BETWEEN, that are used inside a WHERE clause?
What is the difference between IN and BETWEEN, that are used inside a WHERE clause?  What is the difference between IN and BETWEEN, that are used inside a WHERE clause?   Hi, The BETWEEN clause is used to fetch a range 

IDE Questions

what is the difference between the eclipse and myeclipse - IDE Questions
what is the difference between the eclipse and myeclipse  what is the difference between the eclipse and myeclipse  Hi Friend, Difference: Eclipse is an IDE or platform for developing, whereas MyEclipse 

SQL Question

Difference between not null and primary key in mysql
Difference between not null and primary key in mysql  Explain not null and primary key in mysql 

Core Java

Difference between equals() and == ?
Difference between equals() and == ? In this section you will find the difference between equals() and ==. When we create a object using new keyword.... But one more difference is that equals() is a method and "= =" 

Programming Tutorials

Difference between the local and class variable.
class. Below two program are shown which help you to understand the difference between the class and local variable. Showing Local Variable 

Framework Questions

Difference between getting a document using DOMParser & DocumentBuilderFactory !!!
Difference between getting a document using DOMParser & DocumentBuilderFactory !!!  Hi, In DOM tutorials, on one page a document is formed using.... I could not understand the difference between these 2 methods.. Can anyone 

Java Server Faces Questions

What is the difference between component and tag in JSF?
What is the difference between component and tag in JSF?  Please let me know,becaus i am new to jsf and am confusing 

PHP Questions

What is the difference between GET and POST method?
What is the difference between GET and POST method?  In PHP, both GET... there is a lots of difference between the both. Can anyone please explain...;difference between get and post method in PHP POST method is more secure than GET 

Advertisements Advertisements
 

 

 

DMCA.com