zoukankan      html  css  js  c++  java
  • 第十周上机作业

    1.

    package llll;
    
    public class student {
    
        String  name=new String("该学生还未命名"); 
        double achievement;   
         
    public student(){   
    }
    
     public student(String str,double achievement){ 
            this.name=str;
            this.achievement=achievement;
     }
     
     void set(String str,double achievement){  
     this.name=str;
     this.achievement=achievement;
         }
    
    void get(){
     
            System.out.println("该学生姓名为:"+name);
            System.out.println("该学生成绩为:"+achievement);
         }
    }
    package llll;
    
    public class t {
           public static void main(String args[]){
    student A=new student();
    A.set(" 小明",90);
    A.get();
    student B=new student("小王",60);
    B.get();
    }
    
    }

    2

    package finish;
    
    
    public class ttt {
    
        public void Test() {
            System.out.println("无参的调用方法被调用了");
        }
    }
    package finish;
    
    public class b extends ttt {
        
    
            public static void main(String[] args) {
                ttt z=new ttt();
                z.Test();
            }
    
        }

    3.

    package finish;
    
    
    public class ttt {
    
        String name;
        String color;
    
        public static void main(String[] args) {
            ttt c1=new ttt("benchi","红色");
            ttt c2=new ttt("dazhong","黑色");
        }
    
        public ttt(String name1, String color1) {
            name = name1;
            color = color1;
            run();
        }
    
        public void run() {
            System.out.println(color + "的" + name + "正在跑。");
        }
    
    }

    4.

    package finish;
    
    
    public class ttt {
    
        public static void main(String[] args) {
              get(9,13);
            }
    
            public static void get(int i, int j) {
                System.out.println(i + j);
            }
        }

    5.

    封装就是:隐藏对象的属性和实现细节,仅对外提供公共访问方式。
    封装的好处:
    重用;
    不必关心具体的实现;
    面向对象三大特征之一;
    具有安全性
    set访问器是给属性赋值的,get访问器是取得属性值的

  • 相关阅读:
    xhEditor struts2实现图片上传
    xhEditor入门基础
    jQuery全屏插件Textarea Fullscreen
    jQuery幻灯片插件Skippr
    jQuery跳房子插件hopscotch
    合理配置SQLSERVER内存
    浅谈SQL Server 对于内存的管理
    SQL Server 临时表和表变量系列之选择篇
    SQLTest系列之INSERT语句测试
    转:表变量与临时表的优缺点
  • 原文地址:https://www.cnblogs.com/dhy-com/p/12842767.html
Copyright © 2011-2022 走看看