answersLogoWhite

0


Best Answer

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

User Avatar

Wiki User

13y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

Unanswerable. Please supply the programming language.

JavaString str = new String(); // Class - String, Object - str
This answer is:
User Avatar

User Avatar

Wiki User

13y ago

You cannot create an object of an anonymous class

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you create an object for anonymous class?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Write a program to create object without name?

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.


What is meant by instancing a class?

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.


What is difference between classes and objects?

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.


How do you create an object type object in c plus plus?

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. }


Compare anonymous class with abstract class?

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.

Related questions

Write a program to create object without name?

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.


What is meant by instancing a class?

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.


How constructor automatically invoked?

when we create the object of that class


What do you mean by Get instance?

It means create an object for a class. Instance refers to the obj of a class.


Short note on inheritance?

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.


What is the name of the class that create object?

I think what you know is called constructor.


What is the eligibility for an object to get cloned?

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


What is difference between classes and objects?

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.


What is an anonymous class in oops?

class is defined in the class


How do you create an object type object in c plus plus?

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. }


How do you create the object?

ClassName instName = new ClassName(); where class name is the class, instName is the variable for the instantiated class, and ClassName() is the constructor.


How do you create object name for child class in c?

child a=new child();