-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInterfaces_main.java
More file actions
45 lines (40 loc) · 1013 Bytes
/
Copy pathInterfaces_main.java
File metadata and controls
45 lines (40 loc) · 1013 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//interface Animal1
//{
// int eyes=2; //public,static,final by default;
// void walk(); //be default abstract
//// Animal(); //error as interfaces cannot have constructor
//// void eat()
//// {
//// //no non abstract functions implementation
//// }
//}
//interface Herbivore
//{
//
//}
//class Horse1 implements Animal1,Herbivore //multiple inheritance in java
//{
// //interfaces uses implements
// public void walk() //error if we not write public because it will be default type then
// {
// System.out.println("walks on 4 legs");
// }
//}
class Student2
{
String name;
static String sch_name; //as it will be same for all objects of Student class so that it becomes common for all
public static void changeschool()
{
sch_name="new school";
}
}
public class Interfaces_main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Student2.sch_name="ABC";
Student2 s2=new Student2();
s2.name="tony";
System.out.println(Student2.sch_name);
}
}