Results 1 to 3 of 3
Thread: Interface Inheritance
- 03-04-2009, 03:29 AM #1
Member
- Join Date
- Feb 2009
- Posts
- 47
- Rep Power
- 0
Interface Inheritance
Whenever I make the class Q, i get a compile error saying "The type Q must implement the inherited abstract method P12.display()"
I get that I have to put the implementation for display() somewhere in Q (or close to in Q..?), but I'm confused by how to do it. I tried putting
Java Code:void display() { System.out.println("DISPLAY"); }
This is my code so far...
Java Code:interface P { String P = "P"; void display(); }
Java Code:interface P1 extends P { String P1 = "P1"; }
Java Code:interface P2 extends P{ void display(); String P2 = "P2"; }
Java Code:interface P12 extends P1, P2{ void display(); String P12 = "P12"; }
Java Code:public class Q implements P12{ }
-
Does your method need to have the "public" keyword at its declaration in Q?
- 03-04-2009, 03:53 AM #3Java Code:
[B]public[/B] void display() { System.out.println("DISPLAY"); }
methods in interfaces are public, when you declared void display(), that's default package which is weaker.Last edited by angryboy; 03-04-2009 at 04:13 AM.
USE CODE TAGS--> [CODE]...[/CODE]
Get NotePad++ (free)
Similar Threads
-
Inheritance
By mew in forum New To JavaReplies: 1Last Post: 12-07-2007, 07:08 PM -
Inheritance in GUI
By Marty in forum SWT / JFaceReplies: 2Last Post: 05-11-2007, 01:54 AM
Bookmarks