• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

interview question

 
Ranch Hand
Posts: 817
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in some interview question ...
i found someone...
can you pls give me the detail answer of each...
I didn't understand thier answer thats why posting here..


Q1. What comes to mind when someone mentions a shallow copy in Java?

A. Object cloning.

???

Q2. How can you minimize the need of garbage collection and make the memory use more effective?

A. Use object pooling and weak object references.



Q3. What comes to mind when you hear about a young generation in Java?

A. Garbage collection.




Q4. You can create an abstract class that contains only abstract methods. On the other hand, you can create an interface that declares the same methods. So can you use abstract classes instead of interfaces?

A. Sometimes. But your class may be a descendent of another class and in this case the interface is your only option.
 
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
i will give ans to u r 1st question
what is mean by shallow copy
it is funda of object serialization and cloninig
u might know what is mean by cloaning most of the time we want to create
copy of object which has same initial state in that case we are using cloaning
class has attributes and properties
whereas object has state and behaviour
instance variables might be primitive or non primitive
when we clone object of class which has non primitive variables only
reference get copied not actual object
this is known as shallow copy
i think u get more accurate and ans in graphical form in Head first java
 
ganesh pol
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ans to ur 2 nd question
try to create anonymus object
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Taken From: amit taneja
Q2. How can you minimize the need of garbage collection and make the memory use more effective?
A. weak object references.


Check this good link for java object references.
http://www.ociweb.com/jnb/archive/jnbJune2000.html


Taken From: amit taneja
Q3. What comes to mind when you hear about a young generation in Java?
A. Garbage collection.


The allocated objects are divided in generations according to their ages, and young generations are checked more often than the older ones. On young generation fill up the objects will be moved up to old generation and permanent generations.

Also you can decide on young generation partitions and sizes with
-XX:NewSize
-XX:MaxNewSize
-XX:NewRatio
-XX:SurvivorRatio

HTH,
Arjun.
 
ganesh pol
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks arjun for sending such a wonderful site
actually i am also looking for diff types of reference
 
author
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Suppose you have the following class:


A shallow copy clones an instance's instance variables. So when copying an instance of Aaa, the values of i, f, and c would be duplicated. That's what you would expect for the primitives i and f, but what's happening with c, which is a reference? Since c is duplicated, the copy points to the same Color object as the original.

Often that's what you want, and when that's the case you can use the version of clone() that you inherit from Object(). But you might want to use a clone of the Color object, instead of referencing the original. (This would happen when you want to modify the clone, without affecting the original.) In this case you're on your own: you have to override clone().
 
Ranch Hand
Posts: 456
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello,

one question from a not-so-native english speaker:

hi
i will give ans to u r 1st question
what is mean by shallow copy
it is funda of object serialization and cloninig
u might know what is mean by cloaning most of the time we want to create
copy of object which has same initial state in that case we are using cloaning
class has attributes and properties
whereas object has state and behaviour
instance variables might be primitive or non primitive
when we clone object of class which has non primitive variables only
reference get copied not actual object
this is known as shallow copy



can we try to stick a bit with the english we all learned at school? answers like this add an additional level of difficulty for me, this sort of acronym-morse-style is really really hard to understand. at least for me ;-)

would be very very nice & cool,

greetings from germany,
jan
 
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree jan, and I am a native english speaker.
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are not alone: http://faq.javaranch.com/view?UseRealWords
 
ganesh pol
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry friends
i regret it 's my mistake from next time onward i will try to post topics not in shortforms.
 
amit taneja
Ranch Hand
Posts: 817
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Arjun K:

The allocated objects are divided in generations according to their ages, and young generations are checked more often than the older ones. On young generation fill up the objects will be moved up to old generation and permanent generations.

Also you can decide on young generation partitions and sizes with
-XX:NewSize
-XX:MaxNewSize
-XX:NewRatio
-XX:SurvivorRatio

HTH,
Arjun.



didn't get it what do u mean by this ??
 
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by amit taneja:
didn't get it what do u mean by this ??



i'm not really sure what you meant, since parsing non-standard english can be a treacherous and difficult job — this is only my third language, after all. but i think the person you were quoting was talking about certain features of a generational garbage collector, such as the one used by Sun's JVM.
 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
good link there arjun...cleared up the idea of weak/strong/soft and phantom references
reply
    Bookmark Topic Watch Topic
  • New Topic