Posts

Showing posts with the label inheritance

Inheritance in Java with example

Image
Inheritance is a concept in java where new classes can be produced from existing classes. The newly created class acquires all the features of existing class from where it is derived.                     Inheritance can be implemented in java using two keywords:           1.    extends              2. implements           Producing new class from existing classes is called inheritance.              •       The newly produced class is called sub class. The original class is called super class.              •       Extends is the keyword use in inheritance. Syntax: 1 class SubClass extends SuperClass              •     Reusability is the main advantage of inheritance              •     Because of reusability developing of software/program becomes easy.              •    Sub class contains a copy of super class              •    In inheritance, we create object to only sub class. Because in sub class it contains all the methods & objects of a cl

Inheritance interview questions and answers in java

Image
Inheritance is one of the oops concept. If any interview you have attended on java developer there must and should be inheritance related questions you will face it. So, here are few of the inheritance questions and answers. If any one of you people are facing more than these interview questions, share with me through "contact me here" gadget or drop me an email to " subbareddynallamachu@gmail.com ". Q1: What is Inheritance in java? A: Deriving new class from existing classes such that the new classes acquire all the features of existing classes is called inheritance. Q2: Why super class members are available in sub class? A: Because, Sub class object contains a copy of Super class object. Q3: What is the advantages of inheritance? A: Inheritance main use is, a programmer reuses the super class code without rewriting it, in creation of sub classes. So, developing classes becomes very easy. Hence, the programmers productivity is increased. Q4: What is the us