Solved

Java Object, interface, HLD and LLD

Posted on 2010-08-22
11
1,428 Views
Last Modified: 2013-11-23
Hi,
I want to know why Object class is superclass for every class(not performance overhead?), why interfaces, and exact details of what is HLD and LLD.
Thanks,
Aneesh.
0
Comment
Question by:ganeshaneesh
  • 4
  • 4
  • 2
  • +1
11 Comments
 
LVL 26

Accepted Solution

by:
ksivananth earned 150 total points
ID: 33498646
because Object class has the methods every class need to have!

Interface, there many reasons,

1. When you there can be many different implementation for a behaviour.
2. To bring high level abstraction( for example role based access )
3. In Java, to achive multiple inheritance...

HLD - High level design( provides high level design info )
LLD - Low level design( provides detailed design info )
0
 

Author Comment

by:ganeshaneesh
ID: 33498813
could you exmplain a bit,
"because Object class has the methods every class need to have!"?
and
HLD - High level design( provides high level design info )
LLD - Low level design( provides detailed design info )
0
 
LVL 12

Assisted Solution

by:marklorenz
marklorenz earned 75 total points
ID: 33500203
1. Object has standard methods, like getting hash map (for sorting) and toString (for display).  It is not much overhead - if it was, the entire class hierarchy would have this problem!

2. Interfaces provide common behavior for classes.  I.e. roles that the objects can play.  This allows a collection of different types of objects to be worked on in the same way (w/o "if" statements to check types).  Interfaces also allow needs for multiple inheritance (subclassing multiple superclasses) to be handled in a cleaner, more elegant way.

3. HLD vs LLD is a judgement call.  In general, you go from HLD to LLD when you add in more details to a design. E.g. HLD might stop with some basic relationships and key public methods; LLD would might add in helper classes and some private methods.

HTH, Mark
0
 
LVL 26

Assisted Solution

by:ksivananth
ksivananth earned 150 total points
ID: 33508141
>>could you exmplain a bit

look at the methods in Object class, they are all needed for each class in one or other context!

HLD, as said highlevel design, it will have limited info on the system as whole. it may talk only high level interfaces, architecture of the app... this will help just understanding the system, less experience programmers may not able to interpret it.

on the other hand LLD will have detailed info on the implementation part( classes and relationship, communication path... etc), can be given to the programmer for coding.
0
 
LVL 40

Assisted Solution

by:gurvinder372
gurvinder372 earned 75 total points
ID: 33566385
I am not sure what the reason behind "why Object class" has anything to do with HLD and DLD.
Some of the reasons are:
1) It is way by which Java mandates every object in the JVM to expose certain methods and properties, for example, getClass() to get the class of any object, and equals() to check if the current object is equal to a certain object, are those methods which all objects in the JVM is suppose to expose.
2) It is way of saying that objects of all classes in JVM are of TYPE Object.
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Comment

by:ganeshaneesh
ID: 33724563
Please close it off.
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 33725835
but have you understood the concept, is your doubt cleared?
0
 

Author Comment

by:ganeshaneesh
ID: 33731883
Actually, my ques is we are not going to use all/few methods of Object class in user class always, though it extends Object class by default. Will not this be a performance hit? What is the key point of extending Object class in user classes?
-Aneesh.
0
 
LVL 26

Expert Comment

by:ksivananth
ID: 33731995
>>Will not this be a performance hit?

what makes you think that?

>>What is the key point of extending Object class in user classes?

as said, methods in Object class are required by all the classes
0
 

Author Comment

by:ganeshaneesh
ID: 33742097
>>what makes you think that?
As I extend a class(default Object class) to my class, though i dont use the methods of its super class, while creating object for my class, it will have the implementions of the Object class also rite? This is a kind of issue with resource utilzation and also access issue(performance overhead) rite?

>>as said, methods in Object class are required by all the classes
Could you tell me why is it(methods of Object class) required?

Aneesh.
0
 
LVL 26

Expert Comment

by:ksivananth
ID: 33742131
>>while creating object for my class, it will have the implementions of the Object class also rite? This is a kind of issue with resource utilzation and also access issue(performance overhead) rite?
>>

no, there is no resource overhead on the additional methods, there will be only if the base class has some attributes/fields for which memory has to be allocated when you creat instance.

>>Could you tell me why is it(methods of Object class) required?

for example, getClass method, every instance of a class should be able to tell what type the instance is
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
Transparency shows that a company is the kind of business that it wants people to think it is.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now