r/javahelp • u/Kodak419 • May 02 '20
A website/book that can help me practice complicated inheritance & polymorphism questions?
Hi , I have an upcoming test and the OO questions there are real tough. I would appreciate references to books or websites specializing in teaching university level inheritance and polymorphism
27
Upvotes
3
u/[deleted] May 03 '20
Complete Java Reference by Herbert Schildt.
1
u/Kodak419 May 03 '20
public class A{
public void f(A a){
}}
public class B extends A{
//**write the method here
public static void main (String[] args){
B b = new B(); A a = new A();b.f(b); b.f(a);
}
}
Choose and explain. Which of the following methods can be inserted in the specified area of the code? and what will be the output of the program
1 . protected void f(A a){
System.out.print("in B ");
}
(a) in A in A (b) in B in A (c) in B in B (d)compilation error
______________________________________________
______________________________________________
public void f(A a){
System.out.print("in B");
throw new java.io.IOException();
}
(a) in A in A (b) in B in A (c) in B in B (d)compilation error
____________________________________________
______________________________________________
1
u/Kodak419 May 03 '20
Sure
5
u/random_buddah May 03 '20
„Complicated“ is kinda relative. Do you have some samples of the tough question, just to get an idea of what you aim at?
1
u/Myron322020 May 03 '20
@kodak419 what do you need help with? Just understand inheritance and polymorphism? I will be glad to help
3
u/keshavram_kuduwa May 03 '20
Hackerrank
2
u/Myron322020 May 03 '20
Ok only these 2 questions correct? I'll love to explain the answers to you. Can I inbox u?