1 / 6

面向对象的程序设计

面向对象的程序设计. public class Test0bject { public static void main(String[] args){ Person1 p2=new Person1(); p2.name=" 沙 "; System.out.print(p2.getName()); p2.sleep(); } }. 你知道程序的运行结果吗?. class Person1 { public String name;

ewa
Télécharger la présentation

面向对象的程序设计

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 面向对象的程序设计

  2. public class Test0bject { public static void main(String[] args){ Person1 p2=new Person1(); p2.name="沙"; System.out.print(p2.getName()); p2.sleep(); } } 你知道程序的运行结果吗? class Person1 { public String name; public String getName(){ return name+"有威"; } public void sleep(){ System.out.println("是景山学校的信息技术教师"); } }

  3. public class Test1bject { public static void main(String[] args) { Person p2=new Person(); p2.name="沙"; p2.age=56; System.out.println("我姓"+p2.name); System.out.println("我的姓名是:"+p2.getName()); System.out.print(p2.getName()+"的年龄不是"+p2.age); System.out.println(",实际年龄是:"+p2.setAge(p2.age)); System.out.print(p2.getName()); p2.sleep(); } } 看看下一页,想想程序的运行结果?

  4. class Person { public String name; public int age; public void setName(String n){ name=n; } public String getName(){ return name+"有威"; } public int setAge(int a){ age=a+1; return age; } public void sleep(){ System.out.println("是景山学校的信息技术教师"); } } 程序的运行结果是?

  5. array b=new array ; //创建array类的对象b array类中对象 b的方法

  6. //比赛总分统计 import java.io.*; public class Pingfen_sum { public static void main(String args[])throws IOException { array b=new array(); //创建对象b b.inputArray(); //访问对象b的方法输入数据 b.outputArray(); //访问对象b的方法输出数据 b.sum(); //访问对象b的方法统计总分 System.out.println("总分:"+b.sm); //输出总分 } }

More Related