In Java, what is Instance? How the instance is created for an object or method?
338060
An instance in Java is referred to the Memory block where the Object variables are placed on the HEAP. \n\nSuppose we have the following Object\n\nClass obj{\nprivate int a;\nprivate int b;\n\npublic int Sum(){\nreturn a+b;\n}\n\n}\n\nnow this Objecet (obj) is instanced as follows\n\npuiblic static void main(String argv[]){\nobj myObj = new obj(); //Creates an instance of obj on the heap\nint a =myObj.Sum();//Call to the sum method of the obj class\n}\n\nWhen a class in instantiated all the PUBLIC methods are in scope of the calling class
249182
Final just means that the method (or variable) it refers to cannot be modified on s subclass. It is actually redundant on a static anyway because statics are never part of an oject instance.
701316
Inner Classes \n\nInner classes let you define one class within another. \n\nThey provide a type of scoping for your classes since you can make one class a member of another class.\n\nJust as classes have member variables and methods, a class can also have member classes.\n\nclass Outer { \n/class Inner { } \n}// End of class \n\nif you compile it,\n%javac Outer.java\n\n\nyou’ll end up with two class files:\nOuter.class\nOuter$Inner.class\n\n\ne.g.\n\nclass Outer { \nprivate int x = 5;\n\npublic void outerMethod() {\nInner in = new Inner();\nin.innerMethod();\n}\n\nclass Inner {\npublic void innerMethod() {\nSystem.out.println("Outer variable x is " + x);\n}\n} \n}// End of class \n\n\nYou can create four different types of inner classes, based upon the how and the where of creation. \nNested top-level classes\nIf you declare a class within a class and specify the static modifier, the compiler treats the class just like any other top-level class. Any class outside the declaring class accesses the nested class with the declaring class name acting similarly to a package. eg, outer.inner. Top-level inner classes implicitly have access only to static variables. There can also be inner interfaces. All of these are of the nested top-level variety.\n\nMember classes\nMember inner classes are just like other member methods and member variables and access to the member class is restricted, just like methods and variables. This means a public member class acts similarly to a nested top-level class. The primary difference between member classes and nested top-level classes is that member classes have access to the specific instance of the enclosing class.\n\nLocal classes\nLocal classes are like local variables, specific to a block of code.Their visibility is only within the block of their declaration. In order for the class to be useful beyond the declaration block, it would need to implement a more publicly available interface.Because local classes are not members, the modifiers public, protected, private, and static are not usable.\n\nAnonymous classes \nAnonymous inner classes extend local inner classes one level further. As anonymous classes have no name, you cannot provide a constructor.
293980
an Integer and an int are not the same object.  try int x = Integer.intValue();  where Integer is the name of your Integer
1081144
A static method does not require an instance of an object (which is why you can't use "this" within it), whereas an instance menthod requires you to have an instance of an object.\n\nFor example, if you have a class called "Person":\n\npublic class Person\n{\n     public string FirstName;\n     public string LastName;\n\n     public string GetFullName()\n     {\n            return this.FirstName + " " + this.LastName;\n     }\n\n     static public string GetFullName(string First, string Last)\n     {\n           return First + " " + Last;\n     }\n}\n\nThe first method is an instance method. You would have to call it using an instance of a Person object:\n\nPerson objPerson = new Person;\nobjPerson.FirstName = "John";\nobjPerson.LastName = "Doe";\nResponse.Write( objPerson.GetFullName() );\n\nThe second method is a static method. You don't need a current Person object to execute it.\n\nResponse.Write( Person.GetFullName("John", "Doe") );\n\n\nStatic methods are helpful for when you don't need to the overhead of instancing an entire object just to perform one menial function.
415199
A function, or algorithm, or subprocedure, or method if your talking about Object Oriented Programming. There are a lot of different names for it, but it's basically the same thing.
1106184
Actually, a constructor is often declared to be a private member.\nBy declaring a public constructor, what you are choosing to do, is let other people decide how many instances/objects of that class you want to create.\n\nNow, assume that you want to control the number of objects you want to create. \n\nFor example, consider the case of notepad versus yahoo messenger. You can create as many notepad objects you want. Simply click on the notepad icon and you get a new notepad open infront of you.\n\nHowever irrespective of how many times you click on the yahoo messenger icon on the desktop, the same window keeps popping up for you. That means Microsoft wanted you to create multiple objects of notepad but yahoo wanted to allow you only one object of messenger.\n\nThey way to do what yahoo has done is keep the constructor private. Create a different public static method which can call the constructor to create a new object. This method can also see if an object has already been created and based on that invoke the old object.\n\nThis is the notion of singleton. There are a few other places like factory methods etc where the constructor can be kept private, but more on that later
576922
API stands for application program interface. An API can be said to be a library of functions available to a certain software.\n\nThe Java API for instance contains many functions that can be used when you're programming in Java. An example is if you want to create a graphical user interface; instead of dealing directly with the Operating System (OS) which is very tedious, you just need to call some functions listed in the Java API to use them.
195503
There is no structure in Java.\n\nProbably you are confusing with C++>
1080797
Invoking Object's clone method on an instance that does not implement the Cloneable interface results in the exception CloneNotSupportedException being thrown.\n\nBy convention, classes that implement this interface should override Object.clone (which is protected) with a public method. See Object.clone() for details on overriding this method.\n\nNote that this interface does not contain the clone method. Therefore, it is not possible to clone an object merely by virtue of the fact that it implements this interface. Even if the clone method is invoked reflectively, there is no guarantee that it will succeed. \n\nThat means you cannot simply say implements Cloneable since Cloneable has absolutely no methods. Especially not clone. The Object Interface does have clone. Which has the structure of: protected Object clone() throws CloneNotSupportedException\n\nAs the docs say:\nThe class Object does not itself implement the interface Cloneable, so calling the clone method on an object whose class is Object will result in throwing an exception at run time.
155011
I'm supposing you are talking about C++.\nIn C++ Constructor is called when you are constructing it using new operator. You can pass parameter then.\nObjectpointer=new Object(param1, pram2,....)
598400
There are in fact two types of inheritance in Java:\n - Interface implementation:\n. . . . A Class inherits the method signatures and constants in any interface it implements\n - Class extension:\n. . . . A Class can extend one other class (or an interface can extend one other interface)
329175
I'm assuming your accessing it from another class? \n\nPrivate declaration stops this from occuring. You need to provide a public property ie.\n\nprivate _str as string = ""\nPublic Property etc as string\nGet\nreturn _str\nEnd Get\nSet(value as string)\n_str = value\nEnd Set\nEnd Property\n\nOtherwise if you are accessing a class-scope variable normally, you could do:-\n\nPublic class Class1\n Private Str as string = ""\n Private Sub New()\n   Str = "Hehehe"\n End Sub\nEnd Class\n\nQuestion wasn't clearly stated, but i think that should answer it...
176622
static has two meanings.\n\n\nwhen applied to a method in a class, ... it means that the method will be available without having to instantiate a class.\n\nSay you have a class called: Foo. and a method called Bar(), if the method was static I would use the method like this:\n\nFoo.Bar();\n\nif the method isn't static, you use it like this...\n\nFoo f = new Foo();\nf.Bar();\n\ndo you see the difference? the same exact method is available to many instantiations of a class, while each instantiation has it's own method otherwise... \n\n\nAnother meaning of static is taken from C,C++ and can be applied to a variable.\n\nLets say you have a static variable, it's kinda like a global variable. It will keep it's value from the last run of the function... an example might make this all clear.\n\npublic class Test\n{\n\npublic static void Foo()\n{\nstatic int i = 0;\ni++;\nSystem.out.println(i);\n}\n\npublic void Foo2()\n{\nstatic int i = 0;\ni++;\nSystem.out.println(i);\n}\n\npublic void Foo3()\n{\nint i = 0;\ni++;\nSystem.out.println(i);\n}\npublic static void main(String args[])\n{\n     Test a = new Test();\n     Test b = new Test();\n\n     a.Foo2();\n     b.Foo2();\n     a.Foo2();     \n     b.Foo3();\n     b.Foo3();\n     b.Foo3();\n     Test.Foo();\n     Test.Foo();\n     Test.Foo();\n     \n}\n\n}\n\n\nif you run that program the output should be:\n\n1\n1\n2\n1\n1\n1\n1\n2\n3
358642
class Car {\npublic:\nCar();\n~Car();\nvoid Accelerate( float howmuch );\nvoid Brake( float howmuch );\nint Turn( float howmuch );\nint fuel;\n\nprivate:\nint speed;\nfloat accelerate;\nint SubFuel(int qty);\n};\n\nYou should aleady be familiar with the concept of structures (or structs) in C, a structure contains a series of variables which can be used to group data together. A C++ class does much the same thing, except that it not only provides data but also functions to manipulate that data.\nNow let's examine this code line by line. The first line simply says 'I want to define a class called 'Car', the syntax is similar to that used in a struct, except that whenever you wanted to create a variable of type Car you only have to type Car mycar; rather than class Car mycar;. The third line declares all the variables that follow to be 'public'. This means that they can be accessed by any piece of code, for example:\n\nvoid main( void ) {\nCar mycar;\nint fuel;\n\nmycar.Accelerate( 0.5 ); // Note the use of . to access data members and data functions\nfuel = mycar.fuel;// If you had a pointer to a class then you would use ->, as in a struct\n}\n\nNow the forth line is important, it defines a function called 'Car' with no return type. Because this function has the same name as the class it is treated specially, it is called a constructor because whenever a new version of the class is created the constructor is called to initalise the objects data. The fith line is the opposite, because it is the calss name preceded by a ~ symbol it is called the destructor and is automatically called whenever an object is deleted or removed from memory.\nThe next three lines define three member functions, which can be accessed using the '.' method, these have no special meaning and have to be called manually from code (for example on the sixth line of the 'main' example above accelerate is called for the object 'mycar' of type 'Car'). The nineth line declares a meber variable of type int called fuel, this can be treated in much the same way as you treat a struct's member variable.\nThe tenth line is another improtant one, it tells the compiler that the member functions and variables that follow it ar private, meaning that they can only be accessed by the member functions of the class. In this case only the functions Car, ~Car, Accelerate, Brake, Turn and SubFuel would be able to access 'speed' or 'accelerate'. This is also true of the private member function 'SubFuel'. Finally two variables called speed and accelerate and a function calle SubFuel are defined.\n\nYou have seen that a class can contain member variables that can be public or private depending on who you want to be able to access these functions. It is in fact comon to make all member variables private and use functions to Set and Get them because this has the added advantage of enableing you to 'validate' the new data. In addition to public and private data there is also protected data. Protected data is only accessable by the class itself, derivates (see below) of the class and friends of the class. For example, if you had another calss called Driver and you wanted him to be able to access speed then inserting the following code instead of the private block would give driver access to it:\n\nprotected:\nint speed;\nfriend Driver; // make the class 'Driver' a friend, you can also make functions friends\nprivate:\nfloat accelerate;\nSubFuel(int qty);\n\nSo far you have only seen the declaration of the class, you have not seen the implementation of any of the functions. There are two ways to implement the functions, the first is directly into the class - this method is often used if the function is very short:\n\n// A simplified version of the Car class, demonstarting the simple implementation of the Car constructor\nclass Car\n{\npublic:\nCar() {\nfuel = 100;\n}\nprivate:\ni
382095
java usees wrapper classes...Byte,Integer..they are in java.lang package..\n\nin each such class there is one memeber \nstatic int SIZE\n\nusing that u can find out..\n\neg.System.out.println(Byte.SIZE);\n//The number of bits used to represent a byte value in two's complement binary form\n\nSIMILARITY FOR OTHER DATA TYPES..\n\ncheck out documentation site..or if u have already downloaded doc..then use that..
392172
It is a field access symbol used in object oriented PHP code. You can use it to access functions or properties (variables) belonging to an object. It is similar to '.' notation in Java or C++. So where you would have myObject.someProperty or myObject.someMethod(), you have\nmyObject->someProperty or myObject->someMethod(). \nHope this helps...