Questions tagged [objectinstantiation]
92 questions
35
votes
8 answers
Best way to create instance of child object from parent object
I'm creating a child object from a parent object. So the scenario is that I have an object and a child object which adds a distance property for scenarios where I want to search. I've chosen to use inheritance as my UI works equivalently with either…

Captain John
- 1,859
- 2
- 16
- 30
28
votes
8 answers
Simple hibernate query returning very slowly
I have the following hibernate query:
Query query = session.createQuery("from MyHibernateClass");
List result = query.list();// executes in 7000ms
When logging the sql being executed in MySQL I see
select
…

Trym
- 681
- 1
- 6
- 10
12
votes
8 answers
Instantiate objects without using new operator
In one of the java interview, the following question is asked:
In java is there a way to instantiate an object without using new operator? I replied to him that there is no other way of instantiation. But he asked me how an object in java is…

Arun
- 2,562
- 6
- 25
- 43
9
votes
4 answers
Is Object Literal Instantiation faster than setting properties?
Given the following example, is one objectively better/faster/safer than the other? Should object literal instantiation be a best practice where it is practical?
Where is this inappropriate?
class Person
{
public string name;
public int…

Wesley
- 5,381
- 9
- 42
- 65
7
votes
1 answer
How to create a non-instantiable class?
For one of the project I am currently working I was thinking of creating a class that could not be instantiate by a client and only be supplied an instance of through a particular interface i.e. the client would not be able create further instance…

Bleeding Fingers
- 6,993
- 7
- 46
- 74
6
votes
4 answers
Is it possible to bypass constructors when instantiating objects in Android
Do Android have any way to instantiate objects without calling any of its constructors?
In Java, Sun have sun.reflect.ReflectionFactory.getReflectionFactory().newConstructorForSerialization(), in .Net we have…

Vagaus
- 4,174
- 20
- 31
6
votes
3 answers
Type.GetType case insensitive - WinRT
From microsoft documentation, Type.GetType can be case-insensitive in .NET 4.5. Unfortunately, this is not available in WinRT (Metro/Modern UI/Store apps).
Is there a known workaround ? Because I have to instantiate objects from a protocol which…

Nicolas Voron
- 2,916
- 1
- 21
- 35
5
votes
2 answers
Proper approach for complex / nested JavaScript-object creation within another object
The following code is meant to be a short example for a simple construct of a reusable object. This is a very simple, one level depth object, put as many props and methods as you like and just assign them.
function…

Avia Afer
- 866
- 2
- 8
- 29
5
votes
9 answers
Object instantiation using different Constructors
Recently my teacher was talking about using different constructors to instantiate objects. But I'm really confused about that. For that I wanna understand why the I get the following compile error.
class SuperClass {
void superClass(){
…

Shamal Sandeep
- 263
- 1
- 2
- 9
4
votes
3 answers
Is there a performance hit upon object instantation if the object has many methods?
Just a bit of idle curiosity here.
Basically, if I have an object that only has a few primitive data members, it takes up a small amount of memory and doesn't take very long at all to create. However, what happens if I have a lot of methods…

CodeBunny
- 1,991
- 5
- 22
- 32
4
votes
1 answer
Why this instance creation of reqpro40.applicationclass fails?
I am trying to open a ReqPro project from c# class code. The steps followed are:
Add reference to ReqPro.dll (the extensibility COM dll)
Create a type of ReqPro40.Application and have an instance of ReqPro40.ApplicationClass…

Kangkan
- 15,267
- 10
- 70
- 113
4
votes
3 answers
How java create objects implicitly? Like in case of String class
I can't understand how an object is created implicitly.
Example:
String s = "implicit instantiation";
Can I make my own class whose objects can be created implicitly?

ankur_rajput
- 145
- 2
- 11
4
votes
1 answer
How can I remove all gridlines on an Excel spreadsheet except those explicitly added by me after clearing them all?
Yes, this question has been asked before, but the answer provided does not work for me. To be more specific:
Wanting to only have gridlines where there is data (which I add myself), and remove the lighter gridlines that appear by default everywhere…

B. Clay Shannon-B. Crow Raven
- 8,547
- 144
- 472
- 862
4
votes
1 answer
How to instantiate a service dynamically?
I have a Utils Service which is very heavy. I Want to use some of the functions defined in it on a particular user action. As this service is heavy I want to instantiate it lazily(on user action).
How do I achieve…

Vinay K
- 5,562
- 1
- 18
- 27
4
votes
2 answers
Set Private Class Variables Permanently PHP
The Problem: I would like to either permanently set private variables in a class, and then access them with a getter function from outside the class. The issue is every time I instantiate a new the class and create an object it destroys the…

David Calvin
- 194
- 1
- 11