Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Java Object, interface, HLD and LLD

Posted on 2010-08-22
11
Medium Priority
?
1,477 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 600 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 300 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 26

Assisted Solution

by:ksivananth
ksivananth earned 600 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:Gurvinder Pal Singh
Gurvinder Pal Singh earned 300 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
 

Author Comment

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

Expert Comment

by:Gurvinder Pal Singh
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Online collaboration can help businesses be more efficient, help employees grow their skills and foster a team environment.
This video teaches viewers about errors in exception handling.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

886 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