Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///Java Lab 7
- ///Use Of Interface
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- //ME.java
- package javalab7;
- /**
- *
- * @author student
- */
- public interface ME {
- public void task1(String s);
- public void task2();
- public void task3();
- }
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- //Demo.java
- package javalab7;
- /**
- *
- * @author student
- */
- public class Demo implements ME
- {
- public void task1(String temp)
- {
- System.out.println(temp + "(TASK 1) is executed ");
- }
- public void task2()
- {
- System.out.println("TASK 2 is executed ");
- }
- public void task3()
- {
- System.out.println("TASK 3 is executed ");
- }
- public void DemoOwn()
- {
- System.out.println("DemoOwn is executed ");
- }
- }
- //Demo2.java
- package javalab7;
- /**
- *
- * @author student
- */
- abstract public class Demo2 implements ME{
- public void task1(String temp){
- System.out.println(temp + "(TASK 1) is executed from DEMO2");
- }
- public void task2(){}
- }
- package javalab7;
- /**
- *
- * @author student
- */
- public class JavaLab7 {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- // TODO code application logic here
- Demo obj = new Demo();
- Demo2 obj2 = new Demo2();
- obj.task1("Hello");
- obj.task2();
- obj.task3();
- obj.DemoOwn();
- obj2.task1("HI");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement