关于node.js:后端校招面试突击课4年本科基础大复盘-助力进大厂MK

5次阅读

共计 2254 个字符,预计需要花费 6 分钟才能阅读完成。

download: 后端校招面试突击课,4 年本科根底大复盘 助力进大厂

动态方法:有 static 润饰的方法。

非动态方法:没有 static 润饰的方法。

方法调用:
一动态方法调用 动态方法 / 属性

1)一个类:间接调用。

2)不同类 / 不同文件:

a: 类名. 属性名 / 方法名

b: 实例化对象。类名 对象名 = new 类名();

                                                      对象名. 属性 / 方法

       二动态调用 非动态方法 / 属性

都先实例化对象。类名 对象名 = new 类名();

                                                             对象名. 属性名 / 方法名

       一非动态调用动态方法

       二非动态调用非动态方法

        1)同一类中:间接调用

        2)不同类中:a: 类名 . 方法(只能是动态属性)

b: 实例化对象

总结:可间接调用的三种情况

1. 一个类中 动态调动态。

  1. 一个类中 非动态调用 动态 / 非动态。
  2. 动态 类名. 动态属性 / 动态方法。

复制代码
public class Demo03{

int age;
public static void main(String []args){System.out.println(Demo04.name);// 动态调用动态 1
    Demo04.eat();
    Demo04 d = new Demo04();// 动态调用动态 2
    System.out.println(d.name);
    d.eat();
    Demo03 d1 = new Demo03();// 动态调用非动态
    d1.method();
    System.out.println(d1.age);
}
public void method(){System.out.println("first method");
}

}
复制代码
复制代码
1 public class Demo04{
2 static String name = “ 张三 ”;
3
4 public static void eat(){
5 System.out.println(“ 肉夹馍 ”);
6 }
7 }
复制代码
复制代码
1 public class Demo05{
2 static int age;
3 String name;
4 public static void main(String []args){
5
6 Demo05 d1 = new Demo05();// 动态调非动态 实例化
7 d1.method();
8 }
9
10 public void method(){
11 System.out.println(age); // 非动态调动态
12 method1(); // 非动态调动态
13 System.out.println(name);// 非动态调非动态
14 method2(); // 非动态调非动态
15 System.out.println(“first method”);
16 }
17 public static void method1(){
18 System.out.println(“second method”);
19 }
20 public void method2(){
21 System.out.println(“third method”);
22 }
23 }
复制代码
复制代码
1 public class Demo06{
2
3 public static void main(String []args){
4
5 Demo06 d1 = new Demo06(); // 动态调非动态 实例化
6 d1.method();
7 }
8 public void method(){
9 System.out.println(Person.name); // 非动态调动态
10 Person.method1(); // 非动态调动态
11 Person p = new Person(); // 非动态调非动态 实例化
12 p.method2();
13 System.out.println(“first method”);
14 }
15 }
16 class Person{
17 static String name;
18 int age;
19 public static void method1(){
20 System.out.println(“second method”);
21 }
22 public void method2(){
23 System.out.println(“third method”);
24 }
25 }
复制代码
复制代码
1 public class Demo09{
2 // 实参到形参是单向的,所以在传送过程中形参值发生改变不会影响实参
3 public static void main(String []args){
4 int i =1;
5 String s = “ww”;
6 Demo09 d = new Demo09();
7 d.method(i,s);
8 System.out.println(i);
9 System.out.println(s);
10 }
11 public void method(int i,String s){
12 i = 100;
13 s = “asd”;
14 }
15 public void method1
16 }
复制代码
复制代码
public class ChuanDiZhi{

int x = 3;
public static void main(String args[]){ChuanDiZhi p = new ChuanDiZhi();
    p.x = 9;
    show(p);
    System.out.println(p.x);
}
public static void show(ChuanDiZhi p){p.x = 4;}        

}
复制代码
有无返回值

有 void 润饰,无返回值

int——————>return int 类型的值

string————–>return String 类型的值

数据类型 ——–>return 以后数据类型值

返回类、会合、流等

方法的返回值类型必须和 return 之后的值数据类型一样

正文完
 0