Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Please correct me on this,its very confusing

Please correct me if I am wrong somewhere. I have been taught,that

  1. Every time a class is loaded, a class object is created in heap memory,and its reference by the name of Class is kept in class area
  2. Each and every field,like string,int whatsoever is the is also stored in as objects and its reference is given in class object created
  3. Same goes for method,constructor's etc

now there is a question also,whether all these thing is stored for every object or just one object is created to know about the information

Also do tell me What does this Field class in actual have? like for eg

class b
{
String s="sdnla";
}

and there are two objects of b class,b1 and b2,what does Field class object have?

like image 892
user3380123 Avatar asked Mar 16 '14 18:03

user3380123


People also ask

Which is grammatically correct sentence?

Subject-Verb Agreement. In order for a sentence to be grammatically correct, the subject and verb must both be singular or plural. In other words, the subject and verb must agree with one another in their tense. If the subject is in plural form, the verb should also be in plur al form (and vice versa).

How do I use correct me?

—used as a way of making a statement sound less assertive Correct me if I'm wrong, but I think you owe me another dollar.

How do you use correct me if im wrong?

You say ' correct me if I'm wrong' to indicate that you are not entirely sure that what you are about to say is true. As I recall, but correct me if I'm wrong, it was in a car park in Carmarthen.


1 Answers

In normal circumstances, there is just one Class object per class. Not per object. If Java created all that structure for every object, it would use enormous amounts of memory; far more than is actually needed.

If you are creating multiple classloaders within your application, then you may end up with multiple Class objects per class - one held by each classloader. But very few of us ever do such a thing. You might do this if you were programming an application server, or something of that type.

like image 96
Dawood ibn Kareem Avatar answered Oct 13 '22 01:10

Dawood ibn Kareem