|
|
![]() |
| Thread Tools | Search this Thread |
#1
| |||
| |||
What is the difference between an object and an instance in java? Hi, What is the difference between an object and an instance in JAVA? |
#2
| |||
| |||
Re: What is the difference between an object and an instance in JAVA? object has a memory allocated to it during its creation using the syntax Code: classname var=new classname(); Code: classname varname; |
#3
| |||
| |||
Re: What is the difference between an object and an instance in JAVA? Instance in java... An actual object of a particular class. An instance of a class is created using the new operator followed by the class name. Object in java... When we define a class that does not extend any other class, it implicitly extends java.lang.Object. Also, an anonymous class based on an interface. In general we think instance and objects are same, but they are incorrect. instance will have the both class definiation and the object defination where as in object it will have only the object defination. |
#4
| |||
| |||
Re: What is the difference between an object and an instance in JAVA? An object and an instance are one in the same. The difference is between classes and objects. Anything that is static in a class becomes propery of the class itself. These are things like static variables and static methods. To use things that belong to the class itself, no instance of that class is required. No object is required. Objects, on the other hand, are instances of a class. Any non static method defined in a class requires an instance for it to be used. An example of a method that belongs to a class is the Collections.sort() method. This can be invoked simply by using the actual class. However, adding an object to a LinkedList actually requires an instance of that class to be created. So in short, an object is an instance of a class, so objects and instances are the same thing. |
#5
| |||
| |||
Re: What is the difference between an object and an instance in JAVA? Objects are key to understanding object-oriented technology. Instance Method is a subroutine or function designed to work on the current object. Methods are always part of some class. An instance method has access to all the instance variables, other instance methods, as well as the static class-as-a-whole methods and variables.
__________________ The FIFA Manager 2009 PC Game |
#6
| |||
| |||
Re: What is the difference between an object and an instance in JAVA? The main difference between abstract class and interface is, 1. Abstract class has the constructor, but interface doesn't have. 2. Main reason is abstract class contain the instance variable, that why it has the constructor, where as interface has only constants (final variables and ABSTRACT METHODS). 3. A class which can implement the interface, is not implement all methods which are declared in interface , such class is declared as abstract class. that mean abstract class is a subtype of an interface. This is my conclusion. If you have an queries let me know. |
![]() |
|
Tags: instance, java, object |
Thread Tools | Search this Thread |
|
![]() | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
About instance variables in java | Khaled11 | Software Development | 1 | 19-03-2010 02:38 PM |
Differentiation between C++ object and instance | Ram Bharose | Software Development | 4 | 06-02-2010 01:40 PM |
What is Instance variables in Java? | Owen Fernandes | Software Development | 5 | 23-01-2010 08:27 AM |
Object reference not set to an instance of an object | KAIRU26 | Software Development | 3 | 05-09-2009 08:14 PM |
Object test = new Object() <-- Java, best way in C++ | ADISH | Software Development | 3 | 25-10-2008 02:32 PM |