Solved

Java Object, interface, HLD and LLD

Posted on 2010-08-22
11
1,442 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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
 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Earned Value Management quiz questions 2 37
jar file executable 12 58
servlet and mdb, jms error 1 29
Project roadmap 4 27
Introduction This question got me thinking... (http://www.experts-exchange.com/questions/28707487/GLOBALS.html) Why shouldn't we use Globals? This is a simple question without a simple answer.  How do you explain these concepts to a programmer w…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This video teaches viewers about errors in exception handling.

809 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