aspose file tools*
The moose likes Java in General and the fly likes java doubts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "java doubts" Watch "java doubts" New topic
Author

java doubts

paul rappai
Greenhorn

Joined: Nov 23, 2010
Posts: 12
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
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3097
    
  33

This looks like some quiz for us

Mohamed Sanaulla | My Blog
paul rappai
Greenhorn

Joined: Nov 23, 2010
Posts: 12
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
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

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.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3097
    
  33

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

Joined: Nov 23, 2010
Posts: 12
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...
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19785
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14432
    
  23

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.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3097
    
  33

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

Joined: Oct 27, 2005
Posts: 19785
    
  20

It is, but you also said it didn't make a difference.
paul rappai
Greenhorn

Joined: Nov 23, 2010
Posts: 12
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

Joined: Nov 23, 2010
Posts: 12
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java doubts