亚洲欧洲国产欧美一区精品,激情五月亚洲色五月,最新精品国偷自产在线婷婷,欧美婷婷丁香五月天社区

      考試首頁 | 考試用書 | 培訓(xùn)課程 | 模擬考場 | 考試論壇  
      全國  |             |          |          |          |          |         
        當(dāng)前位置:計算機等級 > 二級考試 > Java語言程序設(shè)計 > 模擬試題 > 文章內(nèi)容
        

      全國計算機等級考試二級Java模擬試題及答案(28)

      中華IT學(xué)院   【 】  [ 2016年11月22日 ]
      1、編寫一個Java程序在屏幕上輸出“Hello!”。
      public class test
      {
      public static void main(String[] args)
      {
      System.out.println("Hello!");
      }
      }
      2、編寫一個Java程序在屏幕上輸出“Hello, world!”。
      public class test
      {
      public static void main(String[] args)
      {
      System.out.println("Hello,world");
      }
      }
      3、編寫一個Java程序在屏幕上輸出“This is java!”。
      public class test
      {
      public static void main(String[] args)
      {
      System.out.println("This is java!");
      }
      }
      4、編寫一個Java程序在屏幕上輸出“This is my program!”
      public class test
      {
      public static void main(String[] args)
      {
      System.out.println("This is my program!");
      }
      }
      5、編寫一個Java程序在屏幕上輸出“How are you?”
      public class test
      {
      public static void main(String[] args)
      {
      System.out.println("How are you?");
      }
      }
      6、編寫一個圓類Circle,該類擁有:
      ①一個成員變量
      Radius(私有,浮點型);? // 存放圓的半徑;
      ②兩個構(gòu)造方法
      Circle( )???????????????? // 將半徑設(shè)為0
      Circle(double? r )???????? //創(chuàng)建Circle對象時將半徑初始化為r
      class Circle{
      private double Radius;
      Circle(){
      Radius=0.0;}
      public Circle(double r){
      this. Radius= r;}
      }
      7、定義一個表示學(xué)生信息的類Student,要求如下:
      。1)類Student的成員變量:
      sNO 表示學(xué)號;sName表示姓名;sSex表示性別;sAge表示年齡;sJava:表示Java課程成績。
      (2)類Student的方法成員:
      getNo():獲得學(xué)號;
      getName():獲得姓名;
      class Student{
      private String sNO;
      private String sName;
      private char sSex;
      private int sAge;
      private int sJava;
      public Student(String sNo, String sName){
      this.sNo = sNo;
      this.sName = sName;? }
      public String getsNo() {
      return sNo; }
      public String getsName() {
      return sName; }
      }
      8、定義一個表示水果的類Fruit,要求如下:
      (1)類的成員變量: fName表示水果名稱,fColor表示水果顏色。
      (2)類的成員方法:getName( ):獲得水果名稱。
      class Fruit{
      private String fName;
      private String fColor;
      public Fruit(String fName, String Fcolor ){
      this.sName = sName;
      this.fColor = fColor;? }
      public String getfName() {
      return fName; }
      }
      9、先定義一個類A(該類有成員變量x和y),再定義類A的子類B(要求B新增成員變量z)。
      class A{
      private int x;
      private int y;
      public A(int x,int y ){
      this.x = x;
      this.y = y;? }
      }
      class B extendsA{
      private int z;
      public B(int z){
      this.z=z;}
      }
      10、先定義一個類A(該類有成員變量x,成員方法f1( )對x賦初值),再定義類A的子類B(要求B新增成員變量y,新增成員方法f2(? )對y賦初值)。
      class A{
      private int x;
      public A(int x, ){
      this.x = x;? }
      public int f1x() {
      return x; }
      }
      class B extendsA{
      private int y;
      public B(int z){
      this.y = y;? }
      public int f2y() {
      return y; }
      }
      分享到:
      本文糾錯】【告訴好友】【打印此文】【返回頂部
      將考試網(wǎng)添加到收藏夾 | 每次上網(wǎng)自動訪問考試網(wǎng) | 復(fù)制本頁地址,傳給QQ/MSN上的好友 | 申請鏈接 | 意見留言 TOP
      關(guān)于本站  網(wǎng)站聲明  廣告服務(wù)  聯(lián)系方式  站內(nèi)導(dǎo)航  考試論壇
      Copyright © 2007-2013 中華考試網(wǎng)(Examw.com) All Rights Reserved