快捷导航
帮助中心知识拓展客服QQ 515224986
扫码加微信
19春学期《JAVA语言程序设计Ⅰ》在线作业3

奥鹏作业答案
奥鹏东北大学作业

一、单选题:
1.[单选题]下列程序段执行后t5的结果是( )。int t1 = 9, t2 = 11, t3=8;int t4,t5;t4 = t1 > t2 ? t1 : t2+ t1;t5 = t4 > t3 ? t4 : t3;
    A.8
    B.20
    C.11
    D.9
    正确答案:——B——
2.[单选题]下面程序的输出结果是什么?
class C1{
static int j=0;
public void method(int a){
j++;
}
}
class Test extends C1{
public int method(){
return j++;
}

public void result(){
method(j);
System.out.println(j+method());
}
public static void main(String args[]){
new Te
    A.0
    B.1
    C.2
    D.3
    正确答案:——C——
3.[单选题]选择正确的叙述.
class Happy extends Frame {
Happy() {
SetLayout(new GridLayout(2,2));
Panel p1 = new Panel();
add(p1);
p1.add( new Button("One"));
Panel p2 = new Panel();
add(p2);
p2.add( new Button("Two"));
add( new Button("Three"));
add( new Button("Four"));
s
    A.当frame调整大小时,按钮Three和Four 的大小也将调整。
    B.当frame调整大小时,所有按钮的大小都将调整。
    C.当frame调整大小时,按钮Two和Four 的大小也将调整。
    D.当frame调整大小时,按钮One和Two 的大小也将调整。
    正确答案:——A——
4.[单选题]已知表达式int m[] = {0, 1, 2, 3, 4, 5, 6 };
下面哪个表达式的值与数组下标量总数相等?
    A.m.length()
    B.m.length
    C.m.length()+1
    D.m.length+1
    正确答案:————
5.[单选题]下列哪个选项的java源文件代码片段是不正确的?
    A.package testpackage;
public class Test{ }
    B.import java.io.*;
package testpackage;
public class Test{ }
    C.import java.io.*;
class Person{ }
public class Test{ }
    D.import java.io.*;
import java.awt.*;
public class Test{ }
    正确答案:————
6.[单选题]下面语句返回的数据类型是什么?
(short)10/10.2*2;
    A.int
    B.double
    C.float
    D.short
    正确答案:————
7.[单选题]下面哪一个类可以访问foo包中的所有变量?
package foo;
class a{int c}
class b{private int d}
class c{public int e}
    A.class a
    B.class b
    C.class c
    D.都不能
    正确答案:————
8.[单选题]设有下面两个类的定义:
class  Person {                     
   long    id;     // 身份证号
   String  name;   // 姓名   
}                                            
class  Student  extends  Person {
           int  score;  // 入学总分
           int  getScore(){
      re
    A.包含关系
    B.继承关系
    C.关联关系
    D.无关系,上述类定义有语法错误
    正确答案:————
9.[单选题]下面的哪些程序段可以正确地获得从命令行传递的参数的个数?
    A.int count = args.length;
    B.int count = args.length-1;
    C.int count=0; while(args[count]!=null)
count++;
    D.int count=0;while
(!(args[count].equals(“”))) count++;    易百教育

    正确答案:————
10.[单选题]顺序执行下列程序语句后,则b的值是
String a="Hello";
String b=a.substring(0,2);
    A.Hello
    B.hello
    C.Hel
    D.null
    正确答案:————
11.[单选题]若有循环:
int x=5,y=20;
do{
    y-=x;
    x++;
  }while(++x<--y);则循环体将被执行( )。
    A.0次
    B.1次
    C.2次
    D.3次
    正确答案:————
12.[单选题]在程序的源文件开始处有下面一行程序:
package awt;
    A.结果是一个编译错误,因为Java已经定义了一个awt包
    B.说明这个文件里的所有的类都应该包含在java.awt包里
    C.说明这个文件里的所有的类都应该包含在自己定义的awt包里
    D.导入你自己定义的awt包里的所有类
    正确答案:————
13.[单选题]如果你有下面的类定义
abstract class Shape{
                abstract void draw();
}
请问,在试图编译下面的类定义时会发生什么情况?
class Square extends Shape{
}
    A.都可以成功编译
    B.Shpe可以编译,而Square不能
    C.Square可以编译,而Shape不能
    D.Shape和Square都不能编译
    正确答案:————
14.[单选题]下列语句序列执行后,j 的值是( )。
Int j=3, i=2;
while( --i!=i/j )
    j=j+2;
    A.2
    B.4
    C.5
    D.6
    正确答案:————
15.[单选题]给出下列代码,如何使成员变量m 被方法fun()直接访问?
class Test
{
private int m;
public static void fun()
{
...
}
}
    A.将private int m 改为protected int m
    B.将private int m 改为 public int m
    C.将private int m 改为 static int m
    D.将private int m 改为 int m
    正确答案:————
16.[单选题]下列代码中,将引起一个编译错误的行是  
1)public class Test{  
2) int m,n;  
3) public Test() {}  
4) public Test(int a) {m=a;}  
5) public static void main(String args[]){  
6) Test t1,t2;  
7) int j,k;  
8) j=0;k=0;  
9) t1=new Test();  
10) t2=new Test(j,k);  
11) }  
12
    A.第3行
    B.第5行
    C.第6行
    D.第10行
    正确答案:————
17.[单选题]已知如下的命令执行
java MyTest a b c
请问哪个语句是正确的?
    A.args[0] = "MyTest a b c"
    B.args[0] = "MyTest"
    C.args[0] = "a"
    D.args[1]= 'b'
    正确答案:————
18.[单选题]若a的值为3时,下列程序段被执行后,c的值是多少?(     )
   c = 1;
   if  ( a>0 )  if  ( a>3 )  c = 2;   else   c = 3;    else   c = 4;
    A.1
    B.2
    C.3
    D.4
    正确答案:————
19.[单选题]下列语句序列执行后,k的值是( )。
int j=8, k=15;
for( int i=2; i!=j; i++ )
{ j-=2; k++; }
    A.15
    B.16
    C.17
    D.18
    正确答案:————
20.[单选题]下列类头定义中,错误的是( )。
    A.class x
   { .... }
    B.public x extends y
   { .... }
    C.public class x extends y
   { .... }
    D.class x extends y implements y1
   { .... }
    正确答案:————
二、多选题:
21.[多选题]已知如下类说明:
public class Test {
private float f = 1.0f;
int m = 12;
static int n=1;
public static void main(String arg[]) {
Test t = new Test();
// 程序代码…
}
}
如下哪个使用是正确的?
    A.t.f
    B.this.n
    C.Test.m
    D.Test.n
    正确答案:————
22.[多选题]String s=”Example String”;
下面哪些语句是正确的?
    A.s>>>=3;
    B.int i=s.length();
    C.s[3]=”x”;
    D.String short_s=s.trim();
    E.String t=”root”+s;
    正确答案:————
23.[多选题]已知如下代码:
switch (m)
{
case 0: System.out.println("Condition 0");
case 1: System.out.println("Condition 1");
case 2: System.out.println("Condition 2");
case 3: System.out.println("Condition 3");break;
default: System.out.println("Other Condition");
}
当m 的
    A.0
    B.1
    C.2
    D.3
    E.4
    F.以上都不是
    正确答案:————
24.[多选题]你怎样从下面main()的调用中访问单词“kiss”?
java lyrics a kiss is but a kiss
    A.args[0]
    B.args[1]
    C.args[2]
    D.args[3]
    E.args[4]
    F.args[5]
    正确答案:————
25.[多选题]假定文件名是“Fred.java”,下面哪个是正确的类声明。
    A.public class Fred{
  public int x = 0;
  public Fred (int x){
  this.x=x;
  }
  }
    B.public class fred{
  public int x = 0;
  public Fred (int x){
  this.x=x;
  }
  }
    C.public class Fred extends MyBaseClass{
  public int x = 0;
}
    正确答案:————
26.[多选题]已知如下代码:
public class Test
{
public static void main(String arg[])
{
int i = 5;
do {
System.out.println(i);
} while (--i>5)
System.out.println("finished");
}
}
执行后的输出结果包括什么?
    A.5
    B.4
    C.6
    D.finished
    E.什么都不输出
    正确答案:————
27.[多选题]请选出创建数组的正确语句。
    A.float f[][] = new float[6][6];
    B.float []f[] = new float[6][6];
    C.float f[][] = new float[][6];
    D.float [][]f = new float[6][6];
    正确答案:————
28.[多选题]在如下源代码文件Test.java中, 哪个是正确的类定义?
    A.public class test {
public int x = 0;
public test(int x)
{
this.x = x;
}
}
    B.public class Test{
public int x=0;
public Test(int x) {
this.x = x;
}
}
    C.public class Test extends T1, T2 {
public int x = 0;
public Test (int x) {
this.x = x;
}
}
    D.public class
    正确答案:————
29.[多选题]针对下面的程序,那些表达式的值是true?
  Class Aclass{
  private long val;
  public Aclass(long v){val=v;}
  public static void main(String args[]){
  Aclass x=new Aclass(10L);
  Aclass y=new Aclass(10L);
  Aclass z=y;
  long a=10L;
  int b=10;
  }
  }
    A.a==b;
    B.a==x;
    C.y==z;
    D.x==y;
    E.a==10.0;
    正确答案:————
30.[多选题]已知如下类定义:
class Base {
public Base (){ //... }
public Base ( int m ){ //... }
protected void fun( int n ){ //... }
}
public class Child extends Base{
// member methods
}
如下哪句可以正确地加入子类中?
    A.private void fun( int n ){ //...}
    B.void fun ( int n ){ //... }
    C.protected void fun ( int n ) { //... }
    D.public void fun ( int n ) { //... }
    正确答案:————
奥鹏作业答案
奥鹏东北大学作业

共 0 个关于本帖的回复 最后回复于 2019-3-17 19:15

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

精彩推荐

    明星用户

    QQ|Archiver|手机版|小黑屋|www.openhelp100.com ( 冀ICP备19026749号-1 )

    GMT+8, 2024-4-30 09:10