• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

java doubts

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When i read through one book(Head first Java).pop up some doubts in core java.

1)what is the difference between below statements?
a=b;
c=b.clone();

2)what is the difference between below statements?
Set s = new HashSet();
HashSet s = new HashSet();

3)What is the use of Transient other than Serialization?

4)By Using Static variables any memory issue?

5)Can be a inner class used as Interface?

6)Use of Observor interface?

7)In java.util.ArrayList java code we can see variables(firstIndex,lastIndex,array) declared as vilotile and

transient why?

8)if we know our requirment is like only 10 objects to be stored. which option we should go Object[] or

collecctions?why?performance ? memory?

9)if child object is serialzied then parent will be automatically serialized?

10)when to use inner class in our project?

11)Object Class is implemented Clonable interface, so child class will be use Clonable features. then why

we need Clonable interface as separate?

12)Will instance variables make any memory issue in Garbage collection?

13)if we have all abstract methods in abstract class then what is main difference in abstract class and

interface in this context?

14)if i want to add a element at particular place in collection object then which type i should use and

why?

15)After use of particular object in business logic method and made that object to null, will imporve

memory performance in terms of GC(garbage)?

16)Why Instance variables of parent are not override by child?

17)Apart from System.Exit and error what all possiblitiy that finally not called?

18)What is Agreegation and Composisition in Terms of JAVA class and Object?

19)Threads have its own stack, what about Heap?

20)when i serialize one object in Web application . where the object will written in server or ObjectStream?

21)What is the Use of serialUID in serialization?

22)if I have static-synchorized-block then will it create any memory issue?like class level lock?

23)if i declare static and final variables.where these variables created in JVM? in heap or stack? will these variables create any GC issues?why non-static variables are not acceessable in static methods

24)Why String class is Final?

25)Any memory/ save in using anonymous class in java?

26)we have Class Variables and Object variables. When a class got garbage collected? Object will be collected,when its not refered?

27)One Thread is in waiting,One Thread is executing sync method with Object lock. when waiting Thread can access sync method?

28)What is the difference in Threads on I/O operations?



Thanks
Paul
 
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This looks like some quiz for us
 
paul rappai
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

mohamed sanaullah wrote:This looks like some quiz for us



Sorry to make this kind of entry here....

After reading Headfirst these doubts popup.....

Could you able to clarify some of my doubts?

Thanks
Paul
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Lots of assignment-like doubts though (which we encourage people not to answer directly). If you tell us what you think the answers are we'll let you know which are right and help with those you can't answer.
 
Mohamed Sanaulla
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I dont think you should be putting all your queries in one go.

paul rappai wrote:When i read through one book(Head first Java).pop up some doubts in core java.

1)what is the difference between below statements?
a=b;
c=b.clone();


clone() creates a copy of the instance which invoked the method. That way you can assign the copy to any reference variable. In the first case both a and b will refer to the same object.

paul rappai wrote:
2)what is the difference between below statements?
Set s = new HashSet();
HashSet s = new HashSet();


No difference- The first one is like- Coding to the Interface.

paul rappai wrote:

9)if child object is serialzied then parent will be automatically serialized?


Yes, so the parent also should implement Serializable.

paul rappai wrote:

10)when to use inner class in our project?


Depends on your requirement.

paul rappai wrote:
11)Object Class is implemented Clonable interface, so child class will be use Clonable features. then why

we need Clonable interface as separate?


Its a Marker interface. You can search for more about it.

paul rappai wrote:

12)Will instance variables make any memory issue in Garbage collection?


Depends on how you are going to use your instance variables.

And I just glanced through the other questions- You should be able to solve them yourselves after reading up some material. Looking at the questions- They seem to be from some kind of assignment? Totally unrelated to each other. Till which chapter have you completed studying from the book- Head First Java?
 
paul rappai
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi mohamed sanaullah ,

Thanks for Quick reply..Head First JAVA...completed in one week...
Parallelly doing some R/D also...Here nobody helps me these doubts.(may taken as simple)..so i posted...These are not any Project related....These comes from my mind with How java behaves at each time...
 
Sheriff
Posts: 22821
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

mohamed sanaullah wrote:

paul rappai wrote:
2)what is the difference between below statements?
Set s = new HashSet();
HashSet s = new HashSet();


No difference- The first one is like- Coding to the Interface.


There is absolutely a big difference. What happens if you don't want a HashSet anymore but prefer a TreeSet?

paul rappai wrote:9)if child object is serialzied then parent will be automatically serialized?


Yes, so the parent also should implement Serializable.


Wrong. The parent should implement Serializable, or it should have a constructor without parameters. In the second case this constructor will be called, in the first case it won't.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

Wow, twenty-eight questions in one post! We normally encourage people to ask one question per post, because discussing many different questions at the same time can become very confusing. But I don't want to tell you to start 28 new topics right now...

Some of the questions you ask (for example about finally blocks, and why String is final) have been discussed here a number of times before. Try using the search functionality of the forum to find more information about those.
 
Mohamed Sanaulla
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Prime wrote:

mohamed sanaullah wrote:

paul rappai wrote:
2)what is the difference between below statements?
Set s = new HashSet();
HashSet s = new HashSet();


No difference- The first one is like- Coding to the Interface.


There is absolutely a big difference. What happens if you don't want a HashSet anymore but prefer a TreeSet?



This way yeah it makes a difference. That's what I thought was Coding to an Interface.

 
Rob Spoor
Sheriff
Posts: 22821
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is, but you also said it didn't make a difference.
 
paul rappai
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jesper de Jong wrote:Welcome to JavaRanch.

Wow, twenty-eight questions in one post! We normally encourage people to ask one question per post, because discussing many different questions at the same time can become very confusing. But I don't want to tell you to start 28 new topics right now...

Some of the questions you ask (for example about finally blocks, and why String is final) have been discussed here a number of times before. Try using the search functionality of the forum to find more information about those.



Thanks for Suggestion...Any way i will keep on trying in same thread..till i am getting right answer....

ok... Now start with First one

1)what is the difference between below statements?
a=b;
c=b.clone();

A)any internal(variable) state difference will happen?
B) as in first line "a" and "b" will be pointing to one object reference?
C) so after second line all three will be pointing one reference?
D) we can make same using reflection package also right?
E) so where come difference in (a=b)(c=b.clone())(reflection)
F)difference in terms of Memory,performance?

Thanks
paul
 
paul rappai
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1)what is the difference between below statements?
a=b;
c=b.clone();

A)any internal(variable) state difference will happen?
B) as in first line "a" and "b" will be pointing to one object reference?
C) so after second line all three will be pointing one reference?
D) we can make same using reflection package also right?
E) so where come difference in (a=b)(c=b.clone())(reflection)
F)difference in terms of Memory,performance?

Thanks
paul
 
Story like this gets better after being told a few times. Or maybe it's just a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic