Guest User

Untitled

a guest
Nov 24th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. //first interface
  2. interface Example1{
  3. public void display1();
  4. }
  5. //second interface
  6. interface Example2 {
  7. public void display2();
  8. }
  9. //This interface is extending both the above interfaces
  10. interface Example3 extends Example1,Example2{
  11. }
  12. class Example4 implements Example3{
  13. public void display1(){
  14. System.out.println("display2 method");
  15. }
  16. public void display2(){
  17. System.out.println("display3 method");
  18. }
  19. }
  20. class Demo{
  21. public static void main(String args[]){
  22. Example4 obj=new Example4();
  23. obj.display1();
  24. }
  25. }
  26.  
  27. Output:
  28.  
  29. display2 method
  30.  
  31. abstrac class می تواند توسط یک کلاس یا کلاس انتزاعی گسترش یابد یا به ارث برده شود
  32. class Example1{
  33. public void display1(){
  34. System.out.println("display1 method");
  35. }
  36. }
  37. abstract class Example2{
  38. public void display2(){
  39. System.out.println("display2 method");
  40. }
  41. }
  42. abstract class Example3 extends Example2{
  43. abstract void display3();
  44. }
  45. class Example4 extends Example3{
  46. public void display2(){
  47. System.out.println("Example4-display2 method");
  48. }
  49. public void display3(){
  50. System.out.println("display3 method");
  51. }
  52. }
  53. class Demo{
  54. public static void main(String args[]){
  55. Example4 obj=new Example4();
  56. obj.display2();
  57. }
  58. }
Add Comment
Please, Sign In to add comment