public class Class1 {
protected InnerClass1 ic;
public Class1() {
ic = new InnerClass1();
}
public void displayStrings() {
System.out.println(ic.getString() + ".");
System.out.println(ic.getAnotherString() + ".");
}
static public void main(String[] args) {
Class1 c1 = new Class1();
c1.displayStrings();
}
protected class InnerClass1 {
public String getString() {
return "InnerClass1: getString invoked";
}
public String getAnotherString() {
return "InnerClass1: getAnotherString invoked";
}
}
}
we can do like . crieate inner class instanve in side of main class defalut consiter . use the object we do the our bz logic
Unanswerable. Please supply the programming language.
You cannot create an object of an anonymous class
You cannot create an object without a name. The name identifies the object. If you really mean anonymous classes, then the following is an example of an anonymous class (a class with no identifier):typedef struct {unsigned x;unsigned y;} POINT;There are some restrictions with regards anonymous classes:They can have no constructors or destructor.They cannot be returned from functions.They cannot be passed as type-checked arguments to functions.
The class can be considered a template to create objects. When you create an object, you create it on the basis of the specified class - the object is an instance of the class, and the act of creating the object is also known as "instantiating" the class.
Posted by : Govind Singh Lodhithese are the following differences between java class and object.1. Class is a way of bind data member and method in single unit where as a object is a value form of a class or a instance of a class that means allocating sufficient amount of memory space.2. When we define a class ,there is no memory space allocated for data member of a class where as when we create a object of a class memory space is allocated for data members of a class.3.Class will have exist logically where as object will have exist physically.4.One class can have only one name where as corresponding one class we can create multiple object.5.Class load in main memory by using class loader subsystem where as after load class we can create multiple objects of a class.
An object is simply an instance of a class. #include<iostream> class my_object {}; int main() { my_object X; // instantiate an instance of the class my_object, identified as X. }
Abstract Classes contain the work abstract in it. It is used when you know that you will need to use an object of its type but do not know the inner workings yet. Anonymous classes are those classes that are constructed on the fly. You need to know its inner workings.
You cannot create an object without a name. The name identifies the object. If you really mean anonymous classes, then the following is an example of an anonymous class (a class with no identifier):typedef struct {unsigned x;unsigned y;} POINT;There are some restrictions with regards anonymous classes:They can have no constructors or destructor.They cannot be returned from functions.They cannot be passed as type-checked arguments to functions.
The class can be considered a template to create objects. When you create an object, you create it on the basis of the specified class - the object is an instance of the class, and the act of creating the object is also known as "instantiating" the class.
when we create the object of that class
It means create an object for a class. Instance refers to the obj of a class.
Inheritance is used object oriented program. When you create a class, you can create a child class that inherits methods and data from the parent class.
I think what you know is called constructor.
the most obvious thing to eligible for object is to create his class and define it as opening for the class name and sow for it in last for the code
Posted by : Govind Singh Lodhithese are the following differences between java class and object.1. Class is a way of bind data member and method in single unit where as a object is a value form of a class or a instance of a class that means allocating sufficient amount of memory space.2. When we define a class ,there is no memory space allocated for data member of a class where as when we create a object of a class memory space is allocated for data members of a class.3.Class will have exist logically where as object will have exist physically.4.One class can have only one name where as corresponding one class we can create multiple object.5.Class load in main memory by using class loader subsystem where as after load class we can create multiple objects of a class.
class is defined in the class
An object is simply an instance of a class. #include<iostream> class my_object {}; int main() { my_object X; // instantiate an instance of the class my_object, identified as X. }
ClassName instName = new ClassName(); where class name is the class, instName is the variable for the instantiated class, and ClassName() is the constructor.
child a=new child();