Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Interface Inheritance (Java Program): meaning of each line of the program?

  1. #1
    Junior Member
    Join Date
    Jul 2012
    Posts
    2
    My Mood
    Relaxed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Interface Inheritance (Java Program): meaning of each line of the program?

    Hi guys. I'm just preparing for my exam. help me to explain every line of this program:

    interface J {
        int j = 200;
        int j1();
    }
    interface K {
        double k1();
    }
    interface L extends J,K{
        boolean l1();
    }
    class I implements L{
        public boolean l1() {
            return true;
        }
        public int j1() {
            return 4;
        }
        public double k1() {
            return 6.8;
        }
    }
    class InterfaceInheritance{
        public static void main(String[] g){
            I i=new I();
            System.out.println(i.j);
            System.out.println(i.j1());
            System.out.println(i.k1());
            System.out.println(i.l1());
        }
    }

    Result :
    200
    4
    6.8
    true

    And My second question is how to create o class that implements the interface j and k. Then, call the method on a main program in class InterfaceInheritance.

    thanks for helping me prepare for the exam
    Last edited by Kifli; July 7th, 2012 at 08:09 AM.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Interface Inheritance (Java Program): meaning of each line of the program?

    You will learn a lot more if you sit down and study the code, research what you don't understand. Asking someone else to explain this code is a vague request - what don't you understand about it? If you have a specific question, ask it.

    This thread has been cross posted here:

    http://www.java-forums.org/new-java/61255-interface-inheritance-create-class-implements-interface.html

    Although cross posting is allowed, for everyone's benefit, please read:

    Java Programming Forums Cross Posting Rules

    The Problems With Cross Posting

    Last edited by copeg; July 8th, 2012 at 10:27 AM.

Similar Threads

  1. Program to read .TXT file one line at a time
    By JustForLawls in forum What's Wrong With My Code?
    Replies: 1
    Last Post: June 27th, 2012, 02:02 PM
  2. Please, help with OOP program with graphical interface
    By tavicz in forum Object Oriented Programming
    Replies: 1
    Last Post: April 29th, 2012, 02:56 PM
  3. writing a program to interface with other programs
    By gib65 in forum File I/O & Other I/O Streams
    Replies: 6
    Last Post: November 4th, 2011, 04:16 PM
  4. Meaning of Java Packages
    By Effrego in forum Java Theory & Questions
    Replies: 1
    Last Post: February 5th, 2011, 05:18 PM
  5. Line Drawing Program
    By The_Mexican in forum What's Wrong With My Code?
    Replies: 5
    Last Post: November 13th, 2010, 03:54 PM

Tags for this Thread