小工具知识网

当前位置: 首页 > 行业知识 > Java基础习题大全

行业知识

Java基础习题大全

2026-10-25 13:44:43 来源:互联网转载

目录

  • 第一章
  • 第二章
  • 第三章
  • 第四章
  • 第五章
  • 第六章
  • 第七章
  • 第八章
  • 第九章
  • 第十章
  • 第十一章
  • 第十二章

    第一章

    下列哪个是JDK提供的编译器?

    A.java.exe

    B.javac.exe

    C.javap.exe

    D.javaw.exe

    下列哪个是Java应用程序主类中正确的main方法?

    A.public void main (String args[ ])

    B.static void main (String args[ ])

    C.public static void Main (String args[])

    D.public static void main (String args[ ])

    下列哪个叙述是正确的?

    A.Java源文件是由若干个书写形式互相独立的类组成。

    B.Java源文件中只能有一个类。

    C.如果源文件中有多个类,那么至少有一个类必须是public类。

    D.Java源文件的扩展名是.txt。

    对于下列源文件,哪个叙述是正确的?

    public class E {     public static void main(String []args) {    System.out.println("ok");           System.out.println("您好");          }}class A {  public static void main(String []args) {    System.out.println("ok");           System.out.println("您好");          }}

    A.源文件名字必须是A.java。

    B.源文件有错误。

    C.源文件必须命名为E.java,编译无错误。有两个主类:E和A。程序可以执行主类E也可以执行主类A。

    D.源文件中的E类不是主类。

    下列哪个叙述是正确的?

    A.Java语言是2005年5月Sun公司推出的编程语言。

    B.Java语言是1995年5月IBM司推出的编程语言。

    C.Java语言的名字是印度尼西亚一个盛产咖啡的岛名。

    D.Java语言的主要贡献者是比尔盖茨。

    下列【1】、【2】、【3】、【4】注释标注的哪行代码有错误?

    Public class Example          //【1】{   public static void main(String args[])   //【2】   {      System.out.println("ok");          //【3】      System.out.println("hello");      System.out.println("您好");         //【4】   } }

    A.1

    B.2

    C.3

    D.4

    下列【1】、【2】、【3】、【4】注释标注的哪行代码有错误?

    public class Example          //【1】{   public static void main(string args[])   //【2】   {      System.out.println("ok");          //【3】      System.out.println("hello");      System.out.println("您好");         //【4】   } }

    A.1

    B.2

    C.3

    D.4

    下列【1】、【2】、【3】、【4】注释标注的哪行代码有错误?

    public class Example          //【1】{   public static void main(String args[])  //【2】   {      System.out.println("ok")            //【3】      System.out.println("hello");      System.out.println("您好");         //【4】   } }

    A.1

    B.2

    C.3

    D.4

    下列哪个是表明Java应用程序主类的main方法?

    A.public void main (String args[ ])

    B.static void main (String args[ ])

    C.public static void Main (String args[])

    D.public static void main (String args[ ])

    下列哪个叙述是正确的?

    A.Java源文件是由若干个书写形式互相独立的类组成。

    B.Java源文件中只能有一个类。

    C.如果源文件中有多个类,那么至少有一个类必须是public类

    D.Java源文件的扩展名是.txt

    下列哪个叙述是正确的?

    A.源文件名字必须是java

    B.如果源文件中有多个类,这些类可以都不是public类

    C.如果源文件中只有一个类,这个类必须是public类

    D.如果源文件中只有一个类,这个类必须是主类.

    下列哪个叙述是正确的?

    A.JDK的全称是Java Development Kit,

    B.可以用Microsoft Word 2010 编写Java源文件,

    C.不用NetBean或MyEclipse就无法开发Java程序,

    D.为了运行Java程序,必须要安装NetBean或MyEclipse。

    java程序运行入口的main方法(即主类的main方法)的返回类型是什么?

    A.void

    B.static

    C.char

    D.int

    对于下列源文件,哪个叙诉是正确的?

    public class Cat {     public void cry() {        System.out.println("maiomaio");       }}

    A.源文件的名字必须是Cat.java。

    B.源文件的名字可以是cat.java。

    C.源文件的名字可以任意。

    D.Cat类是主类。

    对于下列源文件,哪个叙诉是错误的?

    public class Cat {     public void cry() {        System.out.println("maiomaio");     }}class E {   public static void main(String args[]) {       System.out.println("ok");   }}

    A.源文件的名字必须是Cat.java。

    B.源文件的名字可以是E.java。

    C.编译源文件得到Cat.class和E.class两个字节码文件。

    D.E类是主类,java E 来运行程序。

    一个源文件中必须要有public类。(x)

    Java源文件中只能有一个类。(x)

    源文件中如果有多个类,那么至多有一个类可以是public类。(v)

    Java源文件中只能有一个类。(x)

    源文件中如果有多个类,那么至多有一个类可以是public类。(v)

    下列源文件可保存成dog.java。(x)

    public class Dog {    public void cry() {            System.out.println("wangwang");    }}

    Java语言是1995年5月Sun公司推出的编程语言。(v)

    开发Java应用程序的基本步骤是:

    1 编写源文件,2.编译源文件,3.运行程序。(v)

    Java源文件是由若干个书写形式互相独立的类组成。(v)

    下列源文件Dog.java会出现编译错误(v)

    public class Dog {    public void cry() {        System.out.println("wangwang");    }}public class Cat {    public void cry() {        System.out.println("maiomiao");    }}

    如果JDK的安装目录为D:\jdk,也可以临时在命令行编辑path,如图1_1。(v)

    java编译器位于java安装目录的\bin文件夹中。名字是javac.exe。(v)

    java编译器的名字是java.exe。(x)

    下列源文件People.java中People是主类。(v)

    class Hello {    public void speak() {        System.out.println("wangwang");    }}public class People {    public static void main(String args[]) {        System.out.println("你好");    }}

    编译下列源文件的Person.java将得到2个字节码文件:Person.class和Xiti.class。(v)

    public class Person {   void speakHello() {        System.out.print("您好,很高兴认识您");      System.out.println(" nice to meet you");   }}class Xiti {          public static void main(String args[]) {      Person zhang = new Person();      zhang.speakHello();    }}

    第二章

    哪个叙述是错误的?

    A.int [] a,b[];是声明了1个int型一维数组a和1个int型二维数组b。

    B.float a[20];是正确的数组声明。

    C.boolean yes = false;是正确的boolean变量声明。

    D.1e2和2.05E2都是double型常量。

    哪个叙述是错误的?

    A.System是关键字。

    B._class可以作为标识符。

    C.char型字符在Unicode表中的位置范围是0至65535。

    D.对于int a[] = new int[3];a.length的值是3。

    下列哪项字符序列可以是标识符?

    A.true

    B.default

    C._int

    D.good-class

    下列哪一项是正确的float变量的声明?

    A.float foo = 1;

    B.float foo = 1.0;

    C.float foo = 2e1;

    D.float foo = 2.02;

    以下哪一项是正确的char型变量的声明?

    A.char ch = “R”;

    B.char ch = ‘\’

    C.char ch = ‘ABCD’;

    D.char ch = “ABCD”;

    哪个叙述是错误的?

    A.对于int a[][] = new int[6][4];a.length的值是6。

    B.对于int a[][] = new int[2][9];a.length,a[0].length,a[1].length的值都是9。

    C.对于int [] a = new int[3];a[0],a[1],a[2]的值都是0。

    D.float height = 1e1F;是正确的float变量声明。

    对于下列Test.java代码,下列哪个叙述是正确的?

      public class Test{    public static void main(String args[]){        int arr[] = new int[10];        System.out.println(arr[1]);    }}

    A.产生编译错误。

    B.输出null。

    C.编译正确,发生运行异常。

    D.输出:0。

    挑错题(ABCD注释标注的哪行代码有错误?)

    public class Test1{    public static void main(String args[]){        char c =65535;           //A        byte b = 127;           //B        int height = 100;       //C        float f = 3.14;        //D    }}

    A.A

    B.B

    C.C

    D.D

    下列【1】、【2】、【3】、【4】注释标注的哪行代码有错误?

     public class Test {     public static void main(String args[]){        char c ='\uabcg';   //【1】        byte b = 127;     //【2】        int x = 100;      //【3】        float f = 3.14F;  //【4】     } }

    A.【1】

    B.【2】

    C.【3】

    D.【4】

    下列【1】、【2】、【3】、【4】注释标注的哪行代码有错误?

     public class Test {     public static void main(String args[]){        char c ='\uabcf';      //【1】        byte b = 127;          //【2】        int public = 100;      //【3】        float f = 3.14F;      //【4】     } }

    A.【1】

    B.【2】

    C.【3】

    D.【4】

    下列【1】、【2】、【3】、【4】注释标注的哪行代码有错误?

     public class Test {     public static void main(String args[]){        char c =65536;           //【1】        byte b = 127;          //【2】        int height = 100;      //【3】        float f = 3.14F;      //【4】     }}

    A.【1】

    B.【2】

    C.【3】

    D.【4】

    下列【1】、【2】、【3】、【4】注释标注的哪行代码有错误?

    public class Test {    public static void main(String args[]){       int x = 8;       byte b = 127;            b = x;                //【1】       x = 'a';              //【2】       long y= b;            //【3】         float z=(int)6.89 ;   //【4】    }}

    A.【1】

    B.【2】

    C.【3】

    D.【4】

    下列【1】、【2】、【3】、【4】注释标注的哪行代码有错误?

     public class Test {     public static void main(String args[]){         int m = 'a';     //【1】         char ch = m;     //【2】         ch = 97;         //【3】         double t = 0.1;  //【4】     } }

    A.【1】

    B.【2】

    C.【3】

    D.【4】

    下列【1】、【2】、【3】、【4】注释标注的哪行代码有错误?

     public class Test {     public static void main(String args[]){        char c =65535;             //【1】        byte b = 127;               //【2】        unsigned int y = 200;       //【3】        float f = 3.14f;            //【4】     }}

    A.【1】

    B.【2】

    C.【3】

    D.【4】

    下列哪个类型声明的变量可以取true或false两个值?

    A.byte

    B.boolean

    C.char

    D.double

    main是java语言规定的关键字。(x)

    float area = 1e1;是错误的float变量声明。(v)

    byte amount = 128;是正确的byte型变量声明。(x)

    int [] a,b;是声明了2个int型一维数组a和b。(v)

    对于 int [][] a ={{1,2,3},{4,5,6,7}};a[0].length的值是3,a[1].length的值是4。(v)

    对于int a[][] = new int[2][9];a.length的值是2,a[0].length,a[1].length的值都是9。(v)

    boolean yes = TRUE;是正确的boolean变量声明。(x)

    标识符的第一个字符可以是数字。(x)

    标识符的长度最多为30个字符长度。(x)

    *号可以出现在标识符中。(x)

    标识符不能是true、false和null(尽管true、false和null不是Java关键字)。(v)

    汉字可以出现在标识符中。(v)

    3.14是float型常量。(x)

    3.14F和0.618f都是float型常量。(v)

    哪些叙述是正确的?(多选)

    A.char ch = ‘\t’;是正确的char变量声明。

    B.char ch =‘你’;是正确的char变量声明。

    C.char ch =‘\u000M’;是正确的char变量声明。

    D.char ch =‘\0’;是正确的char变量声明。

    第三章

    下列哪个叙述是正确的?

    A.5.0/2+10的结果是double型数据。

    B.(int)5.8+1.0的结果是int型数据。

    C.‘苹’+ '果’的结果是char型数据。

    D.(short)10+'a’的结果是short型数据。

    用下列哪个代码替换程序标注的【代码】会导致编译错误?

    public class E {        public static void main (String args[ ]) {            int m=10,n=0;           while(【代码】) {              n++;         }      }}

    A.m–>0

    B.m++>0

    C.m = 0

    D.m>100&&true

    对于Test.java下列哪个叙述是正确的?

    public class Test {      public static void main (String args[ ]) {        boolean boo = false;       if(boo = true){          System.out.print("hello");          System.out.print("你好");       }       else {          System.out.print("ok");          System.out.print("yes");       }    }}

    A.出现编译错误。

    B.程序的输出结果是hello你好

    C.程序输出的结果是ok

    D.程序输出的结果是okyes

    对于int n=6789;,表达式的值为7的是哪个?

    A.n%10

    B.n/10%10

    C.n/100%10

    D.n/1000%10

    下列哪个代码替换程序标注的【代码】会使得程序输出hello。

    public class Test {      public static void main (String args[ ]) {          int m = 0;         if(【代码】){           System.out.println("您好");         }         else {           System.out.println("hello");         }    }}

    A.m-- 0

    C.m++ > 0

    D.–m

    下列【1】、【2】、【3】、【4】注释标注的哪行代码有错误?

    public class Test {      public static void main (String args[ ]) {         byte b = 'a';   //【1】        int n  =100;        char c = 65;   //【2】        b = b;        //【3】        b = b+1;      //【4】    }}

    A.【1】

    B.【2】

    C.【3】

    D.【4】

    下列【1】、【2】、【3】、【4】注释标注的哪行代码有错误?

    public class Test {      public static void main (String args[ ]) {         char ch = '花';  //【1】        byte n  = -100;        ch = ch-ch;      //【2】        n = n;           //【3】        n = 127;         //【4】    }}

    A.【1】

    B.【2】

    C.【3】

    D.【4】

    下列【1】、【2】、【3】、【4】注释标注的哪行代码有错误?

    public class Test {      public static void main (String args[ ]) {         byte b = 32;       //【1】        int n  =100;        char c = 'A'+b;      //【2】        b = b;              //【3】        int m = b+1;       //【4】    }}

    A.【1】

    B.【2】

    C.【3】

    D.【4】

    下列【1】、【2】、【3】、【4】注释标注的哪行代码有错误?

    public class Test {      public static void main (String args[ ]) {         byte b = 32;       //【1】        char c = 'A';      //【2】        byte n = (byte)c;  //【3】        short m = b+1;     //【4】    }}

    A.【1】

    B.【2】

    C.【3】

    D.【4】

    下列【1】、【2】、【3】、【4】注释标注的哪行代码有错误?

    public class Test {      public static void main (String args[ ]) {        int m = 12;       int n = 12;       int number = 100+'w'; //【1】       switch(number) {                case 12: n++;       //【2】          case 100:n--;       //【3】                   break;          case n  : m++;      //【4】       }    }}

    A.【1】

    B.【2】

    C.【3】

    D.【4】

    下列【1】、【2】、【3】、【4】注释标注的哪行代码有错误?

    public class Test {      public static void main (String args[ ]) {        int m = 12;       int n = 12;       long number = 100;   //【1】       switch(number)       //【2】       {                case 12: n++;                 case 100:n--;     //【3】                   break;          case 12+9  : m++; //【4】       }    }}

    A.【1】

    B.【2】

    C.【3】

    D.【4】

    下列【1】、【2】、【3】、【4】注释标注的哪行代码有错误?

     public class Test {      public static void main (String args[ ]) {         int m =100,n =10;        if(100 = m)      //【1】        {           System.out.println("No");        }        else if(10 == n ) //【2】        {            System.out.println("逻辑相等常量在前是好习惯");        }        else if(100 == m ) //【3】        {             System.out.println("逻辑相等常量在前是好习惯");        }        else if(m != n) //【4】        {                System.out.println("ok");        }    }}

    A.【1】

    B.【2】

    C.【3】

    D.【4】

    下列【1】、【2】、【3】、【4】注释标注的哪行代码有错误?

     public class Test {      public static void main (String args[ ]) {         int a[] = {1,2,3,4};//【1】        for(int n = 0;n  

    A.【1】

    B.【2】

    C.【3】

    D.【4】

    下列【1】、【2】、【3】、【4】注释标注的哪行代码有错误?

    public class Test {      public static void main (String args[ ]) {         byte b =7;        b = 7+120;  //【1】        b = b;      //【2】        b =  b+120; //【3】        b += 120;  //【4】   }}

    A.【1】

    B.【2】

    C.【3】

    D.【4】

    对于下列Test.java下列哪个叙述是正确的?

    public class Test {      public static void main (String args[ ]) {        double m = 0.4;       double n = 0.4F;       if(m == n){            System.out.printf("%s","您好");        }       else {           System.out.printf("%s","hello");       }     }}

    A.出现编译错误。

    B.程序的输出结果是您好。

    C.程序输出的结果是hello。

    D.程序没有输出任何结果。

    下列哪个叙述是错误的?

    A.while(表达式)…语句中的“表达式”的值必须是boolean型数据。。

    B.for(表达式1; 表达式2; 表达式3)…语句中的“表达式2”的值必须是boolean型数据。

    C.if(表达式)…语句中的“表达式”的值必须是boolean型数据。

    D.switch语句中必须要有default选项。

    下列哪个叙述是错误的?

    A.逻辑运算符的运算结果是int型数据。

    B.关系运算符的运算结果是boolean型数据。

    C.逻辑运算符的运算结果是boolean型数据。

    D.逻辑运算符的操作元必须是boolean型数据。

    用下列哪个代码替换程序标注的【代码】会使得程序输出hello。

    public class Test {      public static void main (String args[ ]) {          int m = 0;         if(【代码】){           System.out.println("您好");         }         else {           System.out.println("hello");         }    }}

    A.m-- 0

    C.m++ > 0

    D.–m

    用下列哪个代码替换程序标注的【代码】会导致编译错误?

    public class Test {      public static void main (String args[ ]) {          int m = 0;         if(【代码】){           System.out.println("条件表达式必须是bookean");         }    }}

    A.m-- > 0

    B.++m >0

    C.m = 0

    D.m != 0

    对于下列Test.java下列哪个叙述是正确的?

    public class Test {      public static void main (String args[ ]) {        int m = 10, n = 20;       if(n>m)          System.out.print("hello");          System.out.print("你好");       else          System.out.print("ok");          System.out.print("yes");    }}

    A.出现编译错误。

    B.程序的输出结果是hello你好

    C.程序输出的结果是ok

    D.程序输出的结果是okyes

    关系运算符的运算结果是int型数据。(x)

    表达式5/2的结果是2。(v)

    表达式2>8&&9>2的结果为false。(v)

    while(表达式)…语句中的“表达式”的值必须是boolean型数据。(v)

    在while语句的循环体中,执行break语句的效果是结束while语句。(v)

    表达式2>8||9>2的结果为1。(v)

    12 = 12 是非法的表达式。(v)

    for(表达式1; 表达式2; 表达式3)…语句中的“表达式2”的值必须是boolean型数据。(v)

    逻辑运算符的运算结果是boolean型数据。(v)

    switch语句中必须要有default选项。(x)

    第四章

    下列哪个叙述是正确的?

    A.Java应用程序由若干个类所构成,这些类必须在一个源文件中。

    B.Java应用程序由若干个类所构成,这些类可以在一个源文件中,也可以分布在若干个源文件中,其中必须有一个源文件含有主类。

    C.Java源文件必须含有主类。

    D.Java源文件如果含有主类,主类必须是public类。

    下列哪个叙述是正确的?

    A.成员变量的名字不可以和局部变量的名字相同。

    B.方法的参数的名字可以和方法中声明的局部变量的名字相同。

    C.成员变量没有默认值。

    D.局部变量没有默认值。

    对于下列Hello类,哪个叙述是正确的?

    class Hello {     Hello(int m){     }     int Hello() {         return 20;     }     hello() {     }}

    A.Hello类有两个构造方法。

    B.Hello类的int Hello()方法是错误的方法。

    C.Hello类没有构造方法。

    D.Hello无法通过编译,因为其中的hello方法的方法头是错误的(没有类型)。

    对于下列Dog类,哪个叙述是错误的?

    class Dog {     Dog(int m){      }     Dog(double  m){      }     int Dog(int m){         return 23;     }     void Dog(double m){     }}

    A.Dog(int m)与Dog(double m)是互为重载的构造方法

    B.int Dog(int m)与void Dog(double m)是互为重载的非构造方法

    C.Dog类只有两个构造方法,而且没有无参数的构造方法

    D.Dog类有三个构造方法

    下列哪个叙述是正确的?

    A.成员变量有默认值。

    B.this可以出现在static方法中。

    C.类中的实例方法可以用类名调用。

    D.局部变量也可以用访问修饰符:public,proteced,private修饰。

    对于下列Tom类,哪个叙述是正确的?

    public class Test {    public static void main(String args[]){      Tom cat = new Tom();    }}class Tom {     void  Tom(){         System.out.println("ok");     }     Tom(int m){         System.out.println("你好");     }}

    A.程序运行时输出:ok。

    B.没有构造方法。

    C.有编译错误,因为创建对象cat使用的不是构造方法,java编译器已经不提供默认的构造方法了。

    D.程序运行时无任何输出。

    类是最重要的“数据类型”,类声明的变量被称为对象变量,简称对象。(v)

    构造方法没有类型。(v)

    类中的实例变量在用该类创建对象的时候才会被分配内存空间。(v)

    类中的实例方法可以用类名直接调用。(x)

    局部变量没有默认值。(v)

    构造方法的访问权限可以是public,protected,private或友好的。(v)

    方法中声明的局部变量不可以用访问修饰符:public,proteced,private修饰。(v)

    this可以出现在实例方法和构造方法中。(v)

    成员变量的名字不可以和局部变量的相同。(x)

    static方法不可以重载。(x)

    上机调试题:

    说出下列E类中【代码1】~【代码3】的输出结果。

    class Fish {  int weight = 1;}class Lake {  Fish fish;  void setFish(Fish s){    fish = s;  }  void foodFish(int m) {   fish.weight=fish.weight+m;  }}public class Main {  public static void main(String args[]) {    Fish redFish = new Fish();    System.out.println(redFish.weight); //【代码1】    Lake lake = new Lake();    lake.setFish(redFish);    lake.foodFish(120);    System.out.println(redFish.weight); //【代码2】    System.out.println(lake.fish.weight); //【代码3】  }}

    上机调试题

    请说出A类中System.out.println的输出结果。

    class B {  int x = 100,y = 200;  public void setX(int x) {   x = x;  }  public void setY(int y) {   this.y = y;  }  public int getXYSum() {   return x+y;  }}public class Main {  public static void main(String args[]) {    B b = new B();   b.setX(-100);   b.setY(-200);   System.out.println("sum="+b.getXYSum());  }}

    上机调试题

    请说出A类中System.out.println的输出结果。

    class B {int n;static int sum=0;void setN(int n) {this.n=n;  }  int getSum() {   for(int i=1;i  public static void main(String args[]) {   B b1=new B(),b2=new B();   b1.setN(3);   b2.setN(5);   int s1=b1.getSum();   int s2=b2.getSum();   System.out.println(s1+s2);  }}  double f(int x,double y) {   return x+y;  }  int f(int x,int y) {   return x*y;  }}public class Main {  public static void main(String args[]) {   A a=new A();   System.out.println(a.f(10,10)); //【代码1】   System.out.println(a.f(10,10.0));//【代码2】 }}  public static void main(String args[]) {     f(1,2);     f(-1,-2,-3,-4); //给参数传值时,实参的个数很灵活     f(9,7,6) ;  }  public static void f(int ... x){ //x是可变参数的代表,代表若干个int型参数    for(int i=0;i//x.length是x代表的参数的个数      System.out.println(x[i]); //x[i]是x代表的第i个参数(类似数组)    }  }}  static { //静态块   System.out.println("我是AAA中的静态块!");  }}public class Main {  static { //静态块   System.out.println("我是最先被执行的静态块!");  }  public static void main(String args[]) {   AAA a= new AAA(); //AAA的字节码进入内存   System.out.println("我在了解静态(static)块");    }}    private int x = 120;    protected int y = 20;    int z = 11;    private void f() {        x = 200;        System.out.println(x);      }     void g() {        x = 200;        System.out.println(x);     }}public class E {    public static void main(String args[]) {        Tom tom = new Tom();        tom.x = 22;   //【1】        tom.y = 33;   //【2】        tom.z = 55;   //【3】        tom.g();     //【4】    }}    private int x = 120;    protected int y = 20;    int z = 11;    private void showX() {        System.out.println(x);      }     public void setX(int x) {        this.x = x;        System.out.println(x);     }}public class E {    public static void main(String args[]) {        Tom tom = new Tom();        tom.setX(22);     //【1】        tom.y = 33;       //【2】        tom.z = 55;       //【3】        tom.showX();      //【4】    }}   int f(int x,int y){      int x;      //【1】      int m = y;  //【2】      return m;    }   int A(int m)   //【3】   {      return m;   }}public class E {    public static void main(String args[]) {        A a = new A(); //【4】    }}   public  void f(){   }}   public  void f(){   }   private int f(int x){      return 100+x;   }   protected int f(int x,int y){      return x+y;   }}   static int m;   static void f(){       m = 20 ;          //1   } }class B extends A {   void f()              //2   {  m = 222 ;         //3         } }class E {   public static void main(String args[]) {      A.f();            // 4       }}    protected void speakHello() {}    //1    public abstract static void cry();  //2    static int f(){ return 0 ;}        //3    abstract float g();                //4}               abstract float getFloat (); //1   void f()                //2   { }}public class B extends A {   private float m = 1.0f;     //3   private float getFloat ()   //4   {  return m;   }}   public float getNum() {    return 3.0f;  }   } public class B extends A {    【代码】}   public int i=0;   A(int m) {    i = 1;   } }public class B extends A {  B(int m) {     i = 2;   }   public static void main(String args[]){     B b = new B(100);     System.out.println(b.i); //【代码】  } }   private int money =12;   float height;   int seeMoney(){      return money ;          //1   } }class Son extends Father {   int height;   int lookMoney() {      int m = seeMoney();   //2      return m;                }}class E {   public static void main(String args[]) {      Son erzi = new Son();      erzi.money = 300;     //3      erzi.height = 1.78F; //4   }} double f(double x,double y) {  return x+y; }}class B extends A { double f(int x,int y) {  return x*y; }}public class Main {public static void main(String args[]) {   B b=new B();   System.out.println(b.f(3,5));   //【代码1】   System.out.println(b.f(3.0,5.0)); //【代码2】 }}  public int getNumber(int a) {    return a+1;  }}class B extends A {  public int getNumber (int a) {    return a+100;  }}class Main {  public static void main(String args[]) {    A a = new A();    System.out.println(a.getNumber(10)); //【代码1】    a = new B();    System.out.println(a.getNumber(10)); //【代码2】  }}double f(double x,double y) {   return x+y;  }  static int g(int n) {   return n*n;  }}class B extends A {  double f(double x,double y) {   double m = super.f(x,y);   return m+x*y;  }  static int g(int n) {   int m = A.g(n);    return m+n;  }}public class Main {  public static void main(String args[]) {   B b = new B();   System.out.println(b.f(10.0,8.0));//【代码1】   System.out.println(b.g(3));    //【代码2】   A a = new B();   System.out.println(a.f(10.0,8.0)); //【代码3】   System.out.println(a.g(3));    //【代码4】 }}  int M = 200;  int f();}class ImpCom implements Com {  【代码】}    protected void speakHello();       //1    public abstract static void cry();  //2    int f();                            //3    abstract float g();                //4}   abstract int get();}class People {    int computer(Com com){        return com.get();    }}class E {    public static void main(String args[]){        People p = new People();        int m = p.computer(new Com() {                              int m =100;        //【1】                              static int n =10;  //【2】                              public int get()   //【3】                              {                                return 100+m;    //【4】                              }                           });        System.out.println(m);    }}   abstract int get();}class People {    int computer(Com com){        return com.get();    }}class E {    public static void main(String args[]){        People p = new People();        int m = p.computer(new Com() {                               int m =100;        //【1】                               public int get()   //【2】                               {                                return 100+m;    //【3】                               }                               public static void f(){} //【4】                           });        System.out.println(m);    }}    public static void main(String args[]){      int n = 0,m = 0,t = 1000;      try{  m = Integer.parseInt("8888");            n = Integer.parseInt("ab89"); //【1】      }      n =100;            //【2】      catch(NumberFormatException e) {}      try{  m = Integer.parseInt("aaaa");  //【3】            n = Integer.parseInt("8999"); //【4】      }      catch(NumberFormatException e) {}    }}    public static void main(String args[]){      int n = 0,m = 0,t = 1000;      try{  m = Integer.parseInt("8888"); //【1】            n = Integer.parseInt("ab89"); //【2】            t = Integer.parseInt("1289"); //【3】        }      catch(Exception e) {}               //【4】      catch(NumberFormatException e) {}       }}    public static void main(String args[]){      int n = 0,m = 0,t = 1000;      try{  m =  8888;         //【1】            throw new java.io.IOException("right"); //【2】            t = 1000;         //【3】        }      catch(Exception e) {}   //【4】    }}   public static void main(String[] args){    String strOne="bird";    String strTwo=strOne;    strOne="fly";    System.out.println(strTwo); //【代码】 } }

上一篇:三星手机恢复出厂设置详解,轻松重置,一键搞定!

下一篇:csgo怎么转其他服务器?