Solved

Java Object, interface, HLD and LLD

Posted on 2010-08-22
11
1,435 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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
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

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
servlet filter example 37 63
servlet example 17 32
how to install java on RHEL image on EC2 4 27
jsp insert to database example 2 24
"Disruption" is the most feared word for C-level executives these days. They agonize over their industry being disturbed by another player - most likely by startups.
When you’re making plans to join the modern business race, you should analyze various details that may affect your results. Nowadays, millions of businesses are trying to grow into established and appreciated professional enterprises.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

778 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