Dear Naveen, Ur god of java for beginners ... Awesome teaching ...
@shashgo7 жыл бұрын
Navin, I get why inheriting from multiple classes that implement their methods is not allowed. Its because the parent classes can have the same method implementations and so the compiler would not know which method to inherit. But is it possible to have multiple inheritance fro multiple abstract classes where the parent classes don't implement any of their methods? This should be like inheriting from multiple interfaces, correct? Or does the mere word "class" disallow multiple inheritance from abstract classes?
@shuvshaw95944 жыл бұрын
very helpful
@nittasandhya54136 жыл бұрын
wonderfull
@PratBais5 жыл бұрын
Error class,interface or enum expected while creating 3rd class.
@pradyumnabhat30173 жыл бұрын
Hey there, I guess you haven't changed the object name from "AddSub" to "AddSubMull", Hope this might help.
@manjosh19909 жыл бұрын
Hi, I tried the same code on my computer, class AddSubMul extends AddSub, but got an error enum or interface expected. Does this mean multi-level is also not supported?
@laurynas.k9 жыл бұрын
manjosh ramesh no, your IDE and/or your code is messed up...
@damusingh40668 жыл бұрын
chup be
@pradyumnabhat30173 жыл бұрын
Hey there, I guess you haven't changed the object name from "AddSub" to "AddSubMull", Hope this might help.
@shuvshaw95944 жыл бұрын
package javaapplication132; /* MULTI LEVEL INHERITANCE ILLUSTRATION */ public class JavaApplication132 { public static void main(String[] args) { difference obj = new difference(); // creating object of class addition obj.x=10; // assigning value of the integer obj.y=5; // assigning value of the integer obj.add(); // for addition obj.diff(); // for differnce } } class addition { int x,y, res; // declairing required variables public void add() // creating method add for the operation of addition { res= x+y; //addition operation System.out.println(res); //showing output } } class difference extends addition // now class difference is child class of additon class { public void diff() // creating method diff for the operation of difference { res=x-y; // difference operation System.out.println(res); // showing output } } class multiplication extends difference // now multiplication is child of difference class and can say grand child of addition because difference is child of addition { public void mul() //creating method mul for the operation of multiplication { res=x*y; // multiplication operation System.out.println(res); // showing output } }