Java基础练习题附答案


    Java基础练题 附答案
    简单Java程序调试
    1)Java应程序main方法效定义
    A public static void main()
    B public static void main( String args )
    C public static void main( String args[] )
    D public static void main( Graphics g )
    E public static boolean main( String a[] )
    2) 编译运行代码结果:
    public class MyMain{
    public static void main(String argv){
    Systemoutprintln(Hello cruel world)
    }
    }
    A.编译错误
    B.运行输出 Hello cruel world
    C.编译错运行时指示没定义构造方法
    D.编译错运行时指示没正确定义main方法
    3) 列选项中属Java虚拟机执行特点项:
    A.异常处理 B.线程 C.动态链接 D.简单易学
    4) 属Java语言特点项:
    A.分布式 B 安全性 C 编译执行 D面象
    5) 程序运行结果:
    public class Test{
    public static void main(String argv[ ]){
    Systemoutprintln(x+5)
    }
    }
    A 5 B x5 C x+5 D x5
    6) 程序运行结果:
    public class Test{
    public static void main(String argv[ ]){
    Systemoutprintln(good+morning)
    }
    }
    A goodmorning B good+morning
    C good morning D good+morning
    二Java符号表达式
    1) 现int类型整数double类型数进行加法运算结果类型:
    A.int类型 B double类型 C float类型 D long类型
    2)面程序段输出结果:
    int a 2
    Systemoutprint( a++)
    Systemoutprint( a)
    Systemoutprint(++a)
    A.333 B.334 C.234 D.233
    3) 代码输出结果
    public class Test{
    int x3
    public static void main(String argv[]){
    int x 012
    Systemoutprintln(x)
    }
    }
    A.12   B.012   C.10   D.3
    4) 列定义语句正确:
    A.char cn   B.int i12   C.float f28  D.boolean bnull
    5)检查代码:
    public class Quiz2_l{
    public static void main(String[] args) {
    int a 8
    int b 8
    Systemoutprint(a<<2)
    Systemoutprint( + (b>>1) )
    }
    }
    列条语句正确描述程序编译运行时行
    A.编译成功输出324
    B 编译成功输出164
    C 编译成功输出322147483644
    D 编译成功输出162147483644
    E 编泽器拒绝表达式 b>>负数应>>操作符
    6)代码中变量result类型
    byte b 11
    short s 13
    result b * ++s
    A.byte short int long float double
    B.boolean byte short char int long float double
    C.byte short char int long float double
    D.byte short char
    E.int long float double
    7)代码输出结果:
    Systemoutprintln( +2 + 3)
    Systemoutprintln(2 + 3)
    Systemoutprintln(2 + 3 +)
    Systemoutprintln(2 + +3)
    A.第3行出现编译错误
    B.输出23 5 5 23
    C.输出5 5 5 23
    D.输出 23 5 23 23
    8)设变量说明:
    byte myByte
    int myInt
    long myLong
    char myChar
    float myFloat
    double myDouble
    赋值语句需强制转换
    A.myInt myByte
    B.myInt myLong
    C.myByte 3
    D.myInt myChar
    E.myFloat myDouble
    F.myFloat 3
    G.myDouble 30
    9)考虑两语句:
    1 boolean passingScore false && grade 70
    2 boolean passingScore false & grade 70
    表达式grade 70 什方计算
    A. 1 2中均计算
    B. 1 2中均未计算
    C.1中计算2中未计算
    D.2中计算1中未计算
    E.非法 false 应写 FALSE
    10)设整数x 二进制值10011100 (1 字节表示)执行语句 z二进制值:
    int y 1 << 7
    int z x & y
    A.10000001   B.10000000  C.00000001
    D.10011101   E.10011100
    11) 编译正确?
    A.short myshort 99S
    B.String name 'Excellent tutorial Mr Green'
    C.char c 17c
    D.int z 015
    12) java关键字?
    A.double  B.Switch  C.then  D.instanceof
    13) 程序行输出结果
    Systemoutprintln(010|4)
    A.14 B.0 C.6 D.12
    14) 设变量
    char c 'c'
    int i 10
    double d 10
    long l 1
    String s Hello
    语句编译出错
    A.cc+i B. s+i C. i+s D. c+s
    15) 整型变量ab值定义:
    int a3
    int b4
    表达式 ++ab值:
    A.4 B.false C.3 D.true
    16) 执行列代码输出结果:
    public class test {
    public static void main(String args[]) {
    int a2
    int b3
    int c7
    int da>cac
    dd>>2>b db
    Systemoutprintln(b)
    }
    }
    A.2 B.3 C.5 D.7
    三分支程序设计
    1)列语句片段结果
    int result
    int a17b6
    result(ab>4) abab
    Systemoutprintln(result)
    A 0   B 1 C 2    D 5
    2)程序运行结果:
    1 public class Conditional {
    2 public static void main(String args [] ) {
    3 int x 4
    4 Systemoutprintln( value is +((x >4) 9999 9))
    5 }
    6 }
    A 输出:value is 9999
    B 输出 value is 9
    C 输出 value is 90
    D 第4行出现编译错误
    3)代码段输出结果
    1 int x 0 y 4 z 5
    2 if (x > 2) {
    3 if (y < 5) {
    4 System out println ( message one )
    5 }
    6 else {
    7 Systemoutprintln( message two)
    8 }
    9 }
    10 else if (z > 5) {
    11 Systemoutprintln(message three)
    12 }
    13 else {
    14 Systemoutprintln( message four)
    15 }
    A message one
    B message two
    C message three
    D message four
    4) 程序输出结果:
    public class test {
    public static void main(String args[]) {
    int x1y1z1
    if (x1&&y++1||z++1)
    Systemoutprintln(x+x+y+y+z+z)
    }
    }
    A. x0y2z1
    B. x1y2z1
    C. x0y1z1
    D. x0y2z2
    5) 编译运行代码结果:
    1 public class EqualsTest{
    2 public static void main(String args[]){
    3 byte A(byte)4096
    4 if(A4096) Systemoutprintln(Equal)
    5 else Systemoutprintln(Not Equal)
    6 }
    7 }
    A.第3行出现转换丢失精度编译错误
    B.输出 Not Equal
    C.输出 Equal
    6) 关程序条叙述正确
    1 int j 2
    2 switch ( j ) {
    3 case 2
    4 Systemoutprintln (value is two)
    5 case 2 + 1
    6 Systemoutprintln (value is three)
    7 break
    8 default
    9 Systemoutprintln(value is + j)
    10 break
    11 }
    A 第5行表达式合法
    B 变量j接受switch中表达式byte short intlong类型
    C 输出value is two
    D 输出value is two value is three
    E 输出value is two value is 2
    7)程序编译运行结果:
    1 public class Q10
    2 {
    3 public static void main(String[] args)
    4 {
    5 int i 10
    6 int j 10
    7 boolean b false
    8
    9 if( b i j)
    10 Systemoutprintln(True)
    11 else
    12 Systemoutprintln(False)
    13 }
    14 }
    A 第9行出现编译错误
    B 第9行出现运行错误
    C 输出 True
    D 输出 False
    8)程序编译运行结果?
    class test {
    static boolean check
    public static void main(String args[]) {
    int i
    if(check true)
    i1
    else
    i2
    if(i2) ii+2
    else i i + 4
    Systemoutprintln(i)
    }
    }
    A 3 B 4 C 5 D 6 E 语句if(i2)编译出错
    9) 代码:
    if (a >4)
    Systemoutprintln(test1)
    else if (a >9)
    Systemoutprintln(test2)
    else
    Systemoutprintln(test3)
    a值输出结果test2 ?
    A 0
    B 4
    C 4 9间
    D 9
    E
    10)代码段:
    switch ( x ){
    case 1Systemoutprintln(One)break
    case 2
    case 3Systemoutprintln(Two)break
    defaultSystemoutprintln(end)
    }
    变量x取值列情形时程序输出Two
    A 1 B 2 C 3 D default
    11)程序输出结果
    public class test {
    public static void main(String agrs[]) {
    char c1’B’c2’C’
    if (c1+1 Systemoutprintln(c1)
    }
    }
    A B B b C C D c
    12) 假设aint类型变量初始化1列合法条件语句?
    A if (a) { } B if (a<<3) { }
    C if (a2) { } D if (true) { }
    四循环程序设计
    1)执行程序输出结果
    public class ex2{
    public static void main(String args[]) {
    int f1
    int k
    for (k2k<5k++)
    f*k
    Systemoutprintln(k)
    }
    }
    A 0 B 1 C 5 D 4 E 24
    2) 设类
    class Loop{
    public static void main(String[] agrs) {
    int x0int y0
    outer
    for(x0x<100x++){
    middle
    for(y0y<100y++){
    Systemoutprintln(x+x+ y+y)
    if(y10){ <<>> }
    }
    }
    }
    }
    <<>>处插入什代码结束外循环
    A.continue middle
    B.break outer
    C.break middle
    D.continue outer
    E.none of these
    3)代码运行结果:
    public class Calc {
    public static void main (String args []) {
    int total 0
    for (int i 0 j 10 total > 30 ++i j) {
    Systemoutprintln( i + i + j + j)
    total + (i + j)
    }
    Systemoutprintln(Total + total)
    }
    }
    A 产生运行错误
    B 产生编译错误
    C 输出 Total 0
    D 产生输出
    i 0 j 10
    i 1 j 9
    i 2 j 8
    Total 30
    4)程序运行结果
    public class test {
    public static void main(String args[]) {
    int i0 j2
    do {
    i++i
    j
    } while(j>0)
    Systemoutprintln(i)
    }
    }
    A 0 B 1 C 2  D3
    5)程序运行结果?
    class xyz {
    public static void main(String args[]) {
    int ijk
    for (i 0 i < 3 i++) {
    for(j1 j < 4 j++) {
    for(k2 k<5 k++) {
    if((i j) && (jk))
    Systemoutprintln(i)
    }
    }
    }
    }
    }
    A 0 B 1 C 2 D 3 E 4
    6) 程序运行结果?
    class test {
    public static void main(String args[]) {
    int ij0
    for(i10i<0i) { j++ }
    switch(j) {
    case (0) jj+1
    case (1) jj+2 break
    case (2) jj+3 break
    case (10) jj+10 break
    default break
    }
    Systemoutprintln(j)
    }
    }
    A 0 B 1 C 2 D 3 E 10
    7) 观察程序段
    int i1j10
    do{
    if(i++>j) continue
    } while(i<5)
    执行完ij值分:
    A. i6 j5   B. i5 j5
    C. i6 j4  D. i5 j6
    8)程序输出结果
    public class example {
    public static void main(String args[]) {
    int s0
    for (int i0i<5i++) {
    for (int j10j>3*ij)
    s + i*j
    }
    Systemoutprintln(s)
    }
    }
    A 127 B136 C 147 D153
    9) 程序输出结果
    public class example {
    public static void main(String args[]) {
    int i0
    for (i0i<4i++) {
    if (i3)
    break
    Systemoutprint(i)
    }
    Systemoutprintln(i)
    }
    }
    A0123 B0122 C123 D234
    10) 程序运行结果
    class Prob10 {
    static boolean b1
    public static void main(String [] args) {
    int i1 11
    double f113
    do {
    b1 (f1 > 4) && (i1 < 10)
    f1 + 10
    } while (b1)
    Systemoutprintln(b1 + + i1 + + f1)
    }
    }
    A false943 B true1113
    C false813 D true873
    五方法设计
    1)代码输出结果
    public class Test{
    static int x5
    public static void main(String argv[]){
    change(x)
    x++
    Systemoutprintln(x)
    }
    static void change(int m){
    m+2
    }
    }
    A 7 B 6 C 5 D 8
    2) 代码输出结果
    public class Test{
    int x5
    public static void main(String argv[]){
    Test tnew Test()
    tx++
    change(t)
    Systemoutprintln(tx)
    }
    static void change(Test m){
    mx+2
    }
    }
    A 7 B 6 C 5 D 8
    3) 代码输出结果
    public class Test{
    public static void main(String argv[]){
    String xhello
    change(x)
    Systemoutprintln(x)
    }
    static void change(String m){
    mm+2
    }
    }
    A hello B hello2
    C 编译报错 D 运行报错串整数相加
    4)设类:
    class MyPoint {
    void myMethod() {
    int x y
    x 5 y 3
    Systemoutprint( ( + x + + y + ) )
    switchCoords( x y )
    Systemoutprint( ( + x + + y + ) )
    }
    void switchCoords( int x int y ) {
    int temp
    temp x
    x y
    y temp
    Systemoutprint( ( + x + + y + ) )
    }
    }
    果执行myMethod()方法输出结果
    A (5 3) (5 3) (5 3)
    B (5 3) (3 5) (3 5)
    C (5 3) (3 5) (5 3)
    5)程序输出结果
    public class test {
    public static void main(String args[]) {
    int s0
    for (int k0k<10k++)
    s+method(2k)1
    Systemoutprintln(s)
    }
    public static int method(int nint m) {
    if (m0)
    return 1
    else
    return n*method(nm1)
    }
    }
    A 2048 B 1024 C 2036 D2000
    6) 程序输出结果
    public class test {
    public static void main(String args[]) {
    int m0
    for ( int k0k<2k++)
    method(m++)
    Systemoutprintln(m)
    }
    public static void method(int m) {
    Systemoutprint(m)
    }
    }
    A 000 B 012 C123 D111
     
    六数组
    1)输入命令运行Java应程序
    java MyTest 1 2 3
    命令行参数数组args中值正确?
    A args[0] MyTest 1 2 3
    B args[0] 1 2 3
    C args[0] 1
    D args[1] 1 2 3
    2) 注释Start For loop 处插入段代码实现根变量i值定位数组ia[]元素
    public class Lin{
    public void amethod(){
    int ia[] new int[4]
    Start For loop
    {
    ia[i]i
    Systemoutprintln(ia[i])
    }
    }
    }
    A for (int i0 i < ialength() 1 i++)
    B for (int i0 i< ialength() i++)
    C for (int i1 i < 4 i++)
    D for (int i0 i< ialengthi++)
    3)代码调试结果
    public class Q {
    public static void main(String argv[]) {
    int anar[] new int[5]
    Systemoutprintln(anar[0])
    }
    }
    A 编译错误:anar 引前未初始化
    B null
    C 0
    D 5
    4) 列创建二维整型数组正确语句:
    A int a[][] new int [1010]
    B int a[10][10] new int [][]
    C int a[][] new int [10][10]
    D int []a[] new int [10][10]
    5) 出面代码:
    public class Person{
      static int arr[] new int[10]
      public static void main(String a[]) {
       Systemoutprintln(arr[1])
      }
    }
    说法正确?
    A 编译时产生错误
    B 编译时正确运行时产生错误
    C 输出0
    D 输出null
    6)设说明
    char[] c new char[100]
    c[50]值
    A 50
    B 'u0000'
    C
    D 定
    E null直赋值
    7) 设程序调试结果:
    class Q2 {
    public static void main(String[] args) {
    int[] seeds {123468}
    int n seedslength
    for (int i 0 i < 3 i++)
    for (int k 0 k< n1 k++)
    seeds[k] seeds[k+1]
    for (int i 0 i Systemoutprint(t+seeds[i])
    }
    }
    A.输出: 1 2 3 4 6
    B.输出: 4 6 8 8 8
    C.输出: 2 3 4 6 8
    D.输出: 2 3 4 6
    七类象编程
    1) 程序运行结果:
    public class My{
    int value
    public static void main(String args[]) {
    My xnew My()
    if (xnull)
    Systemoutprintln(No Object)
    else
    Systemoutprintln(xvalue)
    }
    }
    A 0 B 1 C No Object D 编译错误 E null
    (2)程序运行结果:
    public class A {
    static int k3
    public static void main(String[] args) {
    int k4
    A x1new A()
    x1k++
    A x2new A()
    x2k++
    k++
    Systemoutprintln(x1k)
    }
    }
    A 3 B 4 C5 D6 E7
    3) 编译运行程序结果:
    public class A {
    static int k3
    static int m
    public static void main(String[] args) {
    k++
    if (m0)
    Systemoutprintln(k)
    else
    Systemoutprintln(Bk)
    k++
    }
    }
    class B {
    static int k6
    }
    A 3 B 4 C5 D编译错误 E6
    4)编译运行程序结果:
    1 public class Q21 {
    2 int maxElements
    3 void Q21() {
    4 maxElements 100
    5 Systemoutprintln(maxElements)
    6 }
    7 Q21(int i) {
    8 maxElements i
    9 Systemoutprintln(maxElements)
    10 }
    11 public static void main(String[] args) {
    12 Q21 a new Q21()
    13 Q21 b new Q21(999)
    14 }
    15 }
    A 输出100 999
    B 输出999 100
    C 第2行出现编译错误变量 maxElements未初始化
    D 12行出现编译错误
    5)程序调试结果
    public class Scope{
    int i
    public static void main(String argv[]){
    Scope s new Scope()
    samethod()
    }
    public static void amethod(){
    Systemoutprintln(i)
    }
    }
    A 输出结果:0
    B 输出
    C 编译错误
    D 输出null
    6)出面代码:
    public class Person{
      static int arr[] new int[10]
      public static void main(String a[]) {
       Systemoutprintln(arr[1])
      }
    }
    说法正确?
    A 编译时产生错误
    B 编译时正确运行时产生错误
    C 输出0
    D 输出null
    7)程序调试结果?
    public class As{
    int i 10
    int j
    char z 1
    boolean b
    public static void main(String argv[]){
    As a new As()
    aamethod()
    }
    public void amethod(){
    Systemoutprintln(j)
    Systemoutprintln(b)
    }
    }
    A.输出0 false
    B 输出0 true
    C 编译错误b 未初始化
    D 编译错误 z 必须赋字符值
    8)程序调试结果?
    public class MyAr{
    public static void main(String argv[]) {
    MyAr m new MyAr()
    mamethod()
    }
    public void amethod(){
    static int i
    Systemoutprintln(i)
    }
    }
    A 输出结果 0
    B 运行出错
    C 输出结果 null
    D 编译错误
    9) 程序运行结果
    class ValHold{
    public int i 10
    }
    public class ObParm{
    public static void main(String argv[]){
    ObParm o new ObParm()
    oamethod()
    }
    public void amethod(){
    int i 99
    ValHold v new ValHold()
    vi30
    another(vi)
    Systemoutprint( vi )
    }
    public void another(ValHold v int i){
    i0
    vi 20
    ValHold vh new ValHold()
    v vh
    Systemoutprint(vi)
    Systemoutprint(i)
    }
    }
    A.10030 B 20030 C 209930 D 10020
    八继承态
    1)程序调试结果:
    class Base{
    Base(){
    int i 100
    Systemoutprint (i)
    }
    }
    public class Pri extends Base{
    static int i 200
    public static void main(String argv[]){
    Pri p new Pri()
    Systemoutprint(i)
    }
    }
    A.编译错误 B.200 C.100200 D.100
    (2) 程序调试结果:
    public class Test {
    int m5
    public void some(int x) {
    mx
    }
    public static void main(String args []) {
    new Demo()some(7)
    }
    }
    class Demo extends Test {
    int m8
    public void some(int x) {
    supersome(x)
    Systemoutprintln(m)
    }
    }
    A.5 B.8 C.7 D.输出 E.编译错误
    3) 试完成述程序片段:
    public class Point()
    { int xy
    public Point(int xint y)
    {     x      y
    }

    }
    A. Pointx Pointy  B.解 C. x1 y1 D.thisx thisy
    (4)考虑类:
    1 class Test(int i) {
    2 void test(int i) {
    3 Systemoutprintln(I am an int)
    4 }
    5 void test(String s) {
    6 Systemoutprintln(I am a string)
    7 }
    8
    9 public static void main(String args[]) {
    10 Test tnew Test()
    11 char chy
    12 ttest(ch)
    13 }
    14 }
    条真?
    A.行 5 通编译方法覆盖
    B.行 12 通编译 没test()方法含字符参数
    C.代码编译12行出现异常
    D.代码编译产生输出 I am an int
    E.代码编译产生输出 I am a String
    (5) 类Test1定义:
    1.public class Test1{
    2. public float aMethod(float afloat b){ }
    3.
    4.}
    种方法插入行3合法( )
    A.public float aMethod(float a float bfloat c){ }
    B.public float aMethod(float cfloat d){ }
    C.public int aMethod(int a int b){ }
    D.private float aMethod(int aint bint c){ }
    6)考虑代码:
    class Tree{}
    class Pine extends Tree{}
    class Oak extends Tree{}
    public class Forest {
    public static void main( String[] args ) {
    Tree tree new Pine()
    if( tree instanceof Pine )
    Systemoutprintln( Pine )
    if( tree instanceof Tree )
    Systemoutprintln( Tree )
    if( tree instanceof Oak )
    Systemoutprintln( Oak )
    else
    Systemoutprintln( Oops )
    }
    }
    输出结果中?
    A.Pine B.Tree C.Forest D.Oops E.输出
    7)程序编译运行结果?
    abstract class Base{
    abstract public void myfunc()
    public void another(){
    Systemoutprintln(Another method)
    }
    }
    public class Abs extends Base{
    public static void main(String argv[]){
    Abs a new Abs()
    aamethod()
    }
    public void myfunc(){
    Systemoutprintln(My Func)
    }
    public void amethod(){
    myfunc()
    }
    }
    A.输出结果 My Func
    B.编译指示 Base 类中抽象方法
    C.编译通运行时指示Base 类中抽象方法
    D.编译指示Base 类中myfunc方法方法体没谁会喜欢该方法
    8) 程序调试结果?
    class Base{
    public final void amethod(){
    Systemoutprintln(amethod)
    }
    }
    public class Fin extends Base{
    public static void main(String argv[]){
    Base b new Base()
    bamethod()
    }
    }
    A.编译指示带final 方法类必须定义final
    B.编译指示继承含final 方法类
    C.运行错误原Base类没定义final类
    D.运行输出 amethod
    9) 目录编译运行两文件结果
    文件 P1java
    package MyPackage
    class P1{
    void afancymethod(){
    Systemoutprintln(What a fancy method)
    }
    }
    文件 P2java
    public class P2 extends P1{
    public static void main(String argv[]){
    P2 p2 new P2()
    p2afancymethod()
    }
    }
    A.两均通编译P2运行时输出 What a fancy method
    B.没通编译
    C.两均通编译P2运行时出错
    D.P1 通编译P2出现编译错误
    10)程序调试结果?
    public class Outer{
    public String name Outer
    public static void main(String argv[]){
    Inner i new Inner()
    ishowName()
    }
    private class Inner{
    String name new String(Inner)
    void showName(){
    Systemoutprintln(name)
    }
    }
    }
    A.输出结果 Outer
    B.输出结果 Inner
    C.编译错误Inner类定义私访问
    D.创建Inner类实例行出现编译错误
    11) 设代码:
    class Base{}
    public class MyCast extends Base{
    static boolean b1false
    static int i 1
    static double d 101
    public static void main(String argv[]){
    MyCast m new MyCast()
    Base b new Base()
    Here
    }
    }
    Here处插入代码出现编译运行错误
    A.bm B.mb C.d i D.b1 i
    12) 设代码:
    interface IFace{}
    class CFace implements IFace{}
    class Base{}
    public class ObRef extends Base{
    public static void main(String argv[]){
    ObRef obj new ObRef()
    Base b new Base()
    Object obj1 new Object()
    IFace obj2 new CFace()
    Here
    }
    }
    Here处插入代码出现编译运行错误
    A.obj1obj2 B.bobj C.objb D.obj1b
    13) 设类定义:
    class Base{
    public Base(int i){}
    }
    public class MyOver extends Base{
    public static void main(String arg[]){
    MyOver m new MyOver(10)
    }
    MyOver(int i){
    super(i)
    }
    MyOver(String s int i){
    this(i)
    Here
    }
    }
    条语句安排Here处
    A.MyOver m new MyOver()
    B.super()
    C.this(Hello10)
    D.Base b new Base(10)
    14) 设类定义:
    class InOut{
    String s new String(Between)
    public void amethod(final int iArgs){
    int iam
    class Bicycle{
    public void sayHello(){
    Here
    }
    }
    }
    public void another(){
    int iOther
    }
    }
    语句安排Here处
    A Systemoutprintln(s)
    B.Systemoutprintln(iOther)
    C Systemoutprintln(iam)
    D Systemoutprintln(iArgs)
    九常系统类
    1) 关程序段正确说法
    1. String s1Hello
    2. String s2Hello
    3. if(s1 s2)
    4. Systemoutprintln(s1 s2)
    5. if (s1equals(s2))
    6. Systemoutprintln(s1equals(s2) )
    A 行4行6执行
    B 行4执行行6执行
    C 行6执行行4执行
    D 行4行6执行
    2) 产生[20999]间机整数表达式?
    A.(int)(20+Mathrandom()*979)
    B 20+(int)(Mathrandom()*980)
    C (int)Mathrandom()*999
    D 20+(int)Mathrandom()*980
    3) 列程序运行结果:
    public class Example{
      String strnew String(good)
      char[] ch{'a''b''c'}
      public static void main(String args[]){
        Example exnew Example()
        exchange(exstrexch)
        Systemoutprint(exstr+ and )
        Sytemoutprint(exch)
      }
      public void change(String strchar ch[]){
        strtest ok
        ch[0]'g'
      }
    }
    A good and abc
    B good and gbc
    C test ok and abc
    D test ok and gbc
    4) 设程序
    public class test {
    public static void main(String args[]) {
    Integer intObjIntegervalueOf(args[argslength1])
    int i intObjintValue()
    if(argslength > 1)
    Systemoutprintln(i)
    if(argslength > 0)
    Systemoutprintln(i 1)
    else
    Systemoutprintln(i 2)
    }
    }
    运行程序输入命令:
    java test 2
    输出:
    A test B test 1 C 0
    D 1 E 2
    5) 列程序运行结果:
    public class test {
    public static void main(String args[]) {
    int i
    float f 23f
    double d 27
    i ((int)Mathceil(f)) * ((int)Mathround(d))
    Systemoutprintln(i)
    }
    }
    A 4 B 5 C 6
    D 61 E 9
    6)果条件成立javalangMath 类中方法?
    method( 44 ) 4
    A round() B min() C trunc() D abs()
    E floor() F ceil()
    7) set集合处理重复元素
    A.果加入重复元素抛出异常
    B.果加入重复元素add方法返回false
    C 集合通调equals方法返回包含重复值元素
    D 重复值导致编译出错
    8) 方法Vector类中增加新元素方法
    A.addElement B insert C append D addItem
    9) 方法Collection 接口方法
    A iterator B isEmpty C toArray D setText
    十Applet编程
    1)变量初始化象创建参数设置等安排Applet什方法完成
    A.init B start C stop D
    2)部件重绘时方法调面次序?
    A.直接调 paint()
    B.调update update会调 paint()
    C.调repaint()调update() update 调 paint()
    D 调 repaint()直接调 paint
    3) javaawtGraphics 类方法绘制填充矩形
    A.fillRect() B.drawRect() C.fillOval()
    D.drawPolygon() E.drawLine()
    4) 列方法属播放声音方法?
    A. loop() B stop() C start() D play()
    5) Applet画面左角右角画条直线draw处应选择?
    import javaawt*
    import javaapplet*
    public class myApplet extends Applet {
    public void paint(Graphics g) {
    draw
    }
    }
    A gdrawLine(00getHeight()getWidth())
    B gdrawLine(0getWidth()0getHeight())
    C gdrawLine(0getWidth()getHeight()0)
    D gdrawLine(getWidth()getHeight()00)
    6) 列说法错误项?
    A.getDocumentBase()获取包含AppletHTML文件URL
    B.getCodeBase()获取Applet类URL
    C.getParameter(String name)获取标记中参数值
    D.指定参数HTML中没说明Applet停止运行
    7) 列说法错误项?
    A.getImage()方法图否存立返回
    B.getImage()方法调图时候直等图加载完毕返回
    C.getImage()方法时图真正需绘制时数真正加载
    D.网络带宽限制图显示程会慢
    8)HTML文件中通什标记嵌入Applet
    A B C D
    十图形户界面编程
    1) 部件水方会改变垂直方变放什位置
    A.BorderLayout 布局North South位置
    B.FlowLayout 布局第部件
    C.BorderLayout 布局East West位置
    D.BorderLayout 布局Center位置
    E.GridLayout布局中
    2)AWT类中实现部件布局
    A.LayoutManager
    B.GridBagLayout
    C.ActionListener
    D.WindowAdapter
    E.FlowLayout
    3) 容器add( Component comp ) add( String name Component comp ) 方法加入什部件时抛出IllegalArgumentException
    A.Button B.List C.Window D.TextArea
    E.包含容器容器
    4) 设程序:
    import javaawt*
    public class FlowAp extends Frame{
    public static void main(String argv[]){
    FlowAp fanew FlowAp()
    fasetSize(400300)
    fasetVisible(true)
    }
    FlowAp(){
    add(new Button(One))
    add(new Button(Two))
    add(new Button(Three))
    add(new Button(Four))
    }
    }
    描绘应外观
    A.窗体边4标记One Four钮
    B.顶底安排4标记One Four钮
    C.标记 Four钮正中央
    D.运行时指示没设置布局理器错误
    5) 设置前布局理器
    A. setLayout 方法
    B.旦创建部件改变部件布局理器
    C.setLayoutManager 方法
    D.updateLayout 方法
    6) 代码运行外观
    import javaawt*
    public class CompLay extends Frame{
    public static void main(String argv[]){
    CompLay cl new CompLay()
    }
    CompLay(){
    Panel p new Panel()
    psetBackground(Colorpink)
    padd(new Button(One))
    padd(new Button(Two))
    padd(new Button(Three))
    add(Southp)
    setLayout(new FlowLayout())
    setSize(300300)
    setVisible(true)
    }
    }
    A.钮左右次序出现窗体底部
    B.钮左右次序出现窗体顶部
    C.钮显示
    D.钮显示占满整窗体
    7) 程序调试结果
    演示事件处理
    import javaawt*
    import javaawtevent*
    public class MyWc extends Frame implements WindowListener{
    public static void main(String argv[]){
    MyWc mwc new MyWc()
    }
    public void windowClosing(WindowEvent we){
    Systemexit(0)
    }
    public void MyWc(){
    setSize(300300)
    setVisible(true)
    }
    }
    A.编译错误
    B.创建窗体会关闭掉
    C.运行输出
    D.编译错误import语句前注释语句
    8) 叙述正确
    A.果部件注册监听者事件会监听者处理
    B.果部件注册监听者事件监听者处理
    C.部件注册监听者导致编译出错
    D.部件已注册监听者移
    9) 正确事件处理方法
    A.mousePressed(MouseEvent e){}
    B.MousePressed(MouseClick e){}
    C.functionKey(KeyPress k){}
    D.componentAdded(ContainerEvent e){}
    10) 关JDK 11事件处理条真
    A.类实现监听者接口
    B.果类实现监听者接口覆盖方法
    C.MouseMotionAdapter类方法返回类型均void
    11) MenuItem类方法
    A.setVisible( boolean b )
    B.setEnabled( boolean b )
    C.getSize()
    D.setForeground( Color c )
    E.setBackground( Color c )
    12)类中类子类直接创建实例
    A.Panel B.Dialog C.Container D.Frame
    十二异常处理
    1)程序发生什异常?
    class A {
    int x
    public static void main {
    A x
    Systemoutprintln(xx)
    }
    }
    A. IOException
    B InterruptException
    C NullPointerException
    D DataFormatException
    2)设方法:
    public void test() {
    try {
    oneMethod()
    Systemoutprintln(condition 1)
    } catch (ArrayIndexOutOfBoundsException e) {
    Systemoutprintln(condition 2)
    } catch(Exception e) {
    Systemoutprintln(condition 3)
    } finally {
    Systemoutprintln(finally)
    }
    }
    果oneMethod正常运行输出结果中?
    A condition 1
    B condition 2
    C condition 3
    D finally
    3) 设代码
    public void fun () {
    int i
    try
    {
    iSysteminread ()
    Systemoutprintln(Location 1)
    } catch (IOException e) {
    Systemoutprintln(Location 2)
    } finally {
    Systemoutprintln(Location 3)
    }
    Systemoutprintln(Location 4)
    }
    果IOException发生 输出?
    A Location 1
    B Location 2
    C Location 3
    D Location 4
    4) 设代码:
    1 String s null
    2 if ( s null & slength() > 0)
    3 Systemoutprintln(s null & slength() > 0)
    4 if ( s null && slength() > 0)
    5 Systemoutprintln(s null & slength() > 0)
    6 if ( s null || slength() > 0)
    7 Systemoutprintln(s null & slength() > 0)
    8 if ( s null | slength() > 0)
    9 Systemoutprintln(s null | slength() > 0)
    行中会产生空指针异常
    A 24
    B 68
    C 2468
    D 268
    5) 类Test1Test2定义:
    1.public class Test1 {
    2. public float aMethod(float afloat b) throws IOException {
    3. }
    4. }
    5. public class Test2 extends Test1{
    6.
    7. }
    种方法插入行6合法
    Afloat aMethod(float afloat b){ }
    Bpublic int aMethod(int aint b)throws Exception{ }
    Cpublic float aMethod(float pfloat q){ }
    Dpublic int aMethod(int aint b)throws IOException{ }
    6)设代码:
    try {
    tryThis()
    return
    } catch (IOException x1) {
    Systemoutprintln(exception 1)
    return
    } catch (Exception x2) {
    Systemoutprintln(exception 2)
    return
    } finally {
    Systemoutprintln(finally)
    }
    果tryThis() 抛出 NumberFormatException输出结果
    A 输出
    B exception 1 finally
    C exception 2 finally
    D exception 1
    E exception 2
    十三流式输入输出文件处理
    1)RandomAccessFile文件构造方法 
    A.RandomAccessFile(data r)
    B.RandomAccessFile(r data)
    C.RandomAccessFile(data read)
    D.RandomAccessFile(read data)
    2)设代码:
    import javaio*
    public class Th{
    public static void main(String argv[]){
    Th t new Th()
    tamethod()
    }
    public void amethod(){
    try{
    ioCall()
    }catch(IOException ioe){}
    }
    }
    ioCall方法方法体?
    A. public void ioCall () throws IOException{
    DataInputStream din new DataInputStream(Systemin)
    dinreadChar()
    }
    B. public void ioCall () throw IOException{
    DataInputStream din new DataInputStream(Systemin)
    dinreadChar()
    }
    C. public void ioCall (){
    DataInputStream din new DataInputStream(Systemin)
    dinreadChar()
    }
    D. public void ioCall throws IOException(){
    DataInputStream din new DataInputStream(Systemin)
    dinreadChar()
    }
    3)前目录存名Hellotxt文件执行面代码输出结果?
    import javaio*
    public class Mine{
    public static void main(String argv[]){
    Mine mnew Mine( )
    Systemoutprintln(mamethod())
    }
    public int amethod(){
    try{
    FileInputStream filenew FileInputStream(Hellotxt)
    }
    catch(FileNotFoundException e){
    Systemoutprint(No such file found)
    return 1
    }
    catch(IOException e){
    Systemoutprint(Doing finally)
    }
    return 0
    }
    }
    A No such file found
    B No such file found1
    C No such file foundDoing finally1
    D 0
    4) 类创建目录?
    A. File B. DataOutput C. Directory
    D. FileDescriptor E FileOutputStream
    5) 假设raf机访问文件语句编译运行结果?rafseek( raflength() )
    A.代码编译
    B.会出现IOException
    C.文件指针定位文件字符前
    D.文件指针定位文件字符
    6)FileOutputStream 构造方法合法形式?
    A. FileOutputStream( FileDescriptor fd )
    B. FileOutputStream( String n boolean a )
    C. FileOutputStream( boolean a )
    D. FileOutputStream()
    E. FileOutputStream( File f )
    7)编译通
    A.File f new File(autoexecbat)
    B DataInputStream d new DataInputStream(Systemin)
    C OutputStreamWriter o new OutputStreamWriter(Systemout)
    D RandomAccessFile r new RandomAccessFile(OutFile)
    8)程序调试结果:
    import javaio*
    class Base{
    public void amethod()throws FileNotFoundException{}
    }
    public class ExcepDemo extends Base{
    public static void main(String argv[]){
    ExcepDemo e new ExcepDemo()
    }
    public void amethod(){}
    protected ExcepDemo(){
    try{
    DataInputStream din new DataInputStream(Systemin)
    Systemoutprintln(Pausing)
    dinreadByte()
    Systemoutprintln(Continuing)
    thisamethod()
    }catch(IOException ioe) { }
    }
    }
    A 构造方法protected导致编译出错
    B amethod方法未声明异常导致编译出错
    C amethod方法未声明异常导致运行错误
    D 输出显示 Pausing击键显示Continuing
    十四线程编程
    1)什原导致线程停止执行
    A.更高优先级线程开始执行
    B.线程调 wait()方法
    C.线程调yield()方法
    D.线程调 pause()方法
    E.线程调 sleep() 方法
    2)方法实现Runnable接口需?
    A.wait() B.run() C.stop()
    D.update() E.resume()
    3)代码调试结果
    public class Bground extends Thread{
    public static void main(String argv[]){
    Bground b new Bground()
    brun()
    }
    public void start(){
    for (int i 0 i <10 i++){
    Systemoutprintln(Value of i + i)
    }
    }
    }
    A.编译错误没定义线程run方法
    B.没定义线程run方法出现运行错误
    C 编译通运行输出 values 0 to 9
    D 编译通运行输出
    4) 关线程叙述正确:
    A.通继承Thread类实现Runnable接口获类中方法互斥锁定
    B 获象互斥锁定
    C 线程通调象synchronized 方法取象互斥锁定
    D 线程调度算法台独立
    5) 线程类方法
    A.yield()
    B sleep(long msec)
    C go()
    D stop()
    6) 准确描述synchronized关键字
    A.允许两线程行运行互相通信
    B 保证某时刻线程访问方法象
    C 保证允许两更处理时开始结束
    D 保证两更线程时开始结束
    参考答案

    1) C 2)D 3) D 4) C 5) B 6) A

    1)B 2)C 3)C 4)B 5)A 6)E 7) B 8) BE 9) D 10)B
    11)D 12)ACD 13)D 14)B 15)D 16) B

    1)D 2) C 3) D 4) A 5)B 6)D 7) C 8) E 9)E 10) BC
    11) A 12) D

    1)C 2)B 3)C 4)C 5)C 6)D 7)B 8)C 9)A 10)D

    1)B 2)D 3)A 4)C 5)C 6)B

    1)B 2)D 3)C 4)CD 5)C 6)B 7) B

    1)A 2)C 3)B 4)D 5)C 6)A 7)A 8)D 9) D

    1)C 2)B 3)D 4)D 5)ACD 6)ABD 7)A 8)D 9)C 10)D
    11)AC 12)ABD 13) D 14) AD

    1)A 2)B 3)B 4)D 5)E 6)A 7)B 8)A 9)ABC

    1)A 2)C 3)A 4)C 5)D 6)D 7) B 8)A

    1)A 2)BE 3)CE 4)C 5)A 6)B 7)C 8)BD 9)A 10)AC
    11)B 12)C
    十二
    1)C 2) AD 3) BCD 4) D 5) BCD 6) C
    十三
    1) A 2) A 3) B 4) A 5) B 6) ABE 7) ABC 8) D
    十四
    1)ABCE 2)B 3)A 4)CD 5)ABD 6)B

    文档香网(httpswwwxiangdangnet)户传

    《香当网》用户分享的内容,不代表《香当网》观点或立场,请自行判断内容的真实性和可靠性!
    该内容是文档的文本内容,更好的格式请下载文档

    下载文档到电脑,查找使用更方便

    文档的实际排版效果,会与网站的显示效果略有不同!!

    需要 2 香币 [ 分享文档获得香币 ]

    下载文档

    相关文档

    高等数学练习题(附答案)

    《高等数学》专业 年级 学号 姓名 一、判断题. 将√或×填入相应的括号内.(每题2分,共20分)( )1...

    10个月前   
    428    0

    近世代数练习题(附答案)

    《近世代数》练习题(附答案)一.选择题1. 设是实数集, 则对任意的, 代数运算 ( C )(A) 适合结合律但不适合交换律 (B) 适合交换律但不适合结合律(C...

    1年前   
    487    0

    基础会计分录练习题及答案

    基础会计分录练习题及答案基础会计会计分录(一)根据下列经济业务编制会计分录:1、购入材料一批,货款18 000元,增值税率17%,另有外地运费700元,均已通过银行付清,材料未验收入库。2、用...

    3年前   
    1547    0

    《Java语言程序设计-基础篇》答案-第03章

    《Java语言程序设计-基础篇》答案-第03章第3章 控制语句复习题3.1 答:if(i % 2 == 0)System.out.println(“偶数”);elseSystem.out.pr...

    3年前   
    846    0

    java基础回顾与增强

    java基础回顾与加强目录

    6年前   
    804    0

    会计基础练习题

    《会计基础》模拟试卷题一、单项选择题  1、会计的本质是对一定单位的经济事项进行确认、计量、记录和( ),并通过所提供的会计资料,作出预测,参与决策,实行监督。  A、对账 B、计算 C、...

    2年前   
    465    0

    高中文言文特殊句式练习题「附答案」

    高中文言文特殊句式练习题   一、判断句练习题1、“乃”帮助表示判断的一项是( ) A、今君乃亡赵走燕   B、嬴乃夷门抱关者 C...

    2年前   
    702    0

    高中文言文特殊句式练习题(附答案)

    高中文言文特殊句式练习题班级: 姓名 一、选择题检测1、下列各组句子中,句式不相同的一组是(   )A、石之铿然有声者,所在皆是也         如...

    2年前   
    654    0

    《精神科护理学》练习题(附答案)

    第一章、绪论1.关于精神病学的学科地位,以下哪种说法正确A.精神病学是生物医学的分枝学科 B.精神病学是行为医学的分枝学科C.精神病学是社会科学的分枝学科 D.精神病学是临床医学的分枝学科E....

    2年前   
    1551    0

    老年人心理健康及护理练习题题库(附答案)

    老年人心理健康及护理练习题题库(附答案)A1型题1. 老年人的记忆功能下列哪项是错误的( )A. 初级记忆保持得较好 B. 次级记忆减退不明显 C. 老年人意义记忆较好 D. 机械记忆较差 ...

    2年前   
    2737    0

    一次函数练习题(附答案)

    一次函数练习题(附答案)篇一:一次函数测试题及其答案 一次函数测试题 1. 函数 y= 中,自变量x的取值范围是( ) x(ab的图象如图所示,那么a的取值范围是( ) A.a1 C....

    3年前   
    1844    0

    高中地理农业地域类型练习题附答案

    限时规范特训25 农业地域类型时间:45分钟 满分:90分一、选择题(本大题共11小题,每小题4分,共44分。在每小题给出的四个选项中,只有一项是最符合题目要求的。)[2019·山西调研]由于...

    8个月前   
    189    0

    公共基础知识马哲练习题含答案

    公共基础知识马哲练习题含答案

    4年前   
    841    0

    中央电大工商管理专业《基础会计》练习题答案

    工商管理专业《基础会计》练习题答案 《职业技能实训一》工商管理专业《基础会计》练习题答案第1题 按照账户的用途和结构分类,“固定资产”账户属于( C )。C 盘存类账户第2题: 用以记录和证明...

    3年前   
    752    0

    保险基础知识-章节练习题及答案(全部)

        第一章   风险与风险管理 1、从广义上讲风险是指( C  ) A、损失的不确定性                                B、盈利的不确定性 C、既包括...

    7年前   
    6238    0

    《JAVA语言程序设计》试题及答案3

    《JAVA语言程序设计》试题及答案3《JA V A语言程序设计》试题及答案3一、单选题1、下列程序段执行后的结果是( )。String s = new String(“abcdefg“);fo...

    3年前   
    969    0

    《药品基础知识》考试试卷(答案附)

    药品基础知识试题 姓名: 部门: 分数: 一、填空题。每题3分,共30分。1、药品是指用于____...

    2年前   
    977    0

    最新最全2020-2021热工基础题库(附答案)

    最新最全2020-2021热工基础题库(附答案)

    4年前   
    1397    0

    中考历史总复习基础知识默写提纲(附答案)

    岳麓版中考历史总复习基础知识默写提纲(附答案)九年级(上册)1.人和世界被发现的时代分别指什么?2.人被发现的时代的思想核心是: 先驱: 代表作品:3.人被发现的时代...

    4年前   
    2043    0

    java教案

    设计摘要专业 物联网 课程 Java程序设计课时 1 课型 理论+实践班级 18级物联网教材 零基础学Java-明日科技出版章节 面向对象核心技术

    4年前   
    815    0

    文档贡献者

    文***享

    贡献于2022-09-24

    下载需要 2 香币 [香币充值 ]
    亲,您也可以通过 分享原创文档 来获得香币奖励!

    该用户的其他文档