shivaprasad


{ City } hyderabad
< Country > india
* Profession * student
User No # 9830
Total Questions Posted # 1
Total Answers Posted # 4

Total Answers Posted for My Questions # 4
Total Views for My Questions # 5897

Users Marked my Answers as Correct # 291
Users Marked my Answers as Wrong # 52
Questions / { shivaprasad }
Questions Answers Category Views Company eMail

I have a class which is abstract which contains only the abstract methods. This is similar to an interface. Then, if i have given a choice to choose one of them. Which one i have to choose and why?

4 Core Java 5897




Answers / { shivaprasad }

Question { 9555 }

Is multiple inheritance allowed in Java? Why ?


Answer

Multiple inheritance is not allowed in java because it creates
DIAMOND PROBLEM.
DIAMOND PROBLEM: Suppose classes B and C extend A and
class D extends to both B and C(multiple inheritance). Now,
if D calls a method in A then it does not know from which
class it has to inherit(either B or C). This is called
diamond problem.

Is This Answer Correct ?    8 Yes 1 No

Question { 10060 }

Describe inheritance as applied to java?


Answer

Inheritance is a form of software re usability in which new
classes are created from existing classes by absorbing their
attributes and behavior using the key word 'extends'.
The class which absorbs the properties is called 'sub class'
and the class which is used is called 'super class'.
Ex:
class Room
{
void roomAttributes()
{
int roomlength;
int roomheight;
int roombreadth;
String roomname;
}
void roomBehavior()
{
System.out.println("Two windows");
System.out.println("One 6.2*3.5 door");
}
}
public class BedRoom
{
public static void main(String[] args)
{
Room roomobj=new Room();
roomAttributes();
roomBehavior();
int area= room.length*room.breadth*room.height;
}
}
In the above example the room is a super class from which
bedroom(subclass) is inheriting the properties and
attributes. This is simple inheritence.
Similarly, multi level inheritence is also possible.

Ex: class A extends B
class B extends C
class C extends D

But, java does not support multiple inheritance.
Ex: class A extends B, c

For better reference : Deitei & Deitel or Balaguruswamy

Is This Answer Correct ?    2 Yes 1 No


Question { Accenture, 13853 }

In Inheritence concept, i have a static method in super
class and i am inheriting that class to one sub class.in
that case the static method is inherited to sub class or
not????


Answer

Definitely the sub class inherits the static method in
super class.

Is This Answer Correct ?    2 Yes 2 No

Question { 85075 }

what is difference between Exception and Error?


Answer

Exceptions are those which can be handled at the run time
where as errors cannot be handled.
Examples for exceptions: Array out of bonds, attempt to
divide by zero etc.
Exceptions can be handled by handlers using try - catch.

Is This Answer Correct ?    279 Yes 48 No