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

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

一、单选题:
1.[单选题]设有下面两个赋值语句:
      a = Integer.parseInt("1024");
      b = Integer.valueOf("1024").intValue();
   下述说法正确的是(     )。
    A.a是整数类型变量,b是整数类对象。
    B.a是整数类对象,b是整数类型变量。
    C.a和b都是整数类对象并且它们的值相等。
    D.a和b都是整数类型变量并且它们的值相等。
    正确答案:——D——
2.[单选题]下列类头定义中,错误的是( )。
    A.class x
   { .... }
    B.public x extends y
   { .... }
    C.public class x extends y
   { .... }
    D.class x extends y implements y1
   { .... }
    正确答案:——B——
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.[单选题]下面程序的输出结果是什么?
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
    正确答案:————
5.[单选题]给出下列代码,如何使成员变量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
    正确答案:————
6.[单选题]下面程序的输出结果是什么?
class Foo{
static void change(String s){
s=s.replace('j','l');
}

public static void main(String args[]){
String s="java";
change(s);
System.out.println(s);
}
}
    A.lava
    B.java
    C.编译错误
    D.运行时出现异常
    正确答案:————
7.[单选题]下列程序的功能是在监控台上每隔一秒钟显示一个字符串“Hello”,能够填写在程序中下划线位置,使程序完整并能正确运行的语句是  
public class Test implements Runnable{  
public static void main(String args[]){  
Test t=new Test();  
Thread tt=new Thread(t);  
tt.start();  
}  
public void run(){  
for(;;){  
try{
    A.sleep(1000)  
InterruptedException
    B.sleep(1000)  
RuntimeException
    C.Thread.sleep(1000)  
RuntimeException
    D.Thread.sleep(1000)  
InterruptedException
    正确答案:————
8.[单选题]有下面的类:
  public class Example{
  static int x[]=new int[15];
  public static void main(String args[]){
  System.out.println(x[5]);
  }
  }
下面的那些说法是正确的。
    A.编译时出错
    B.运行时出错
    C.输出0
    D.输出null
    正确答案:————
9.[单选题]下面程序运行后I的结果是什么?
Class sree
{
fun(){
static int I =0;
I++;
}
public static void main(String args[])
{
sree obj=new sree();
obj.fun();
obj.fun();
}
    A.编译错误
    B.运行时错误
    C.1
    D.2    易百教育

    正确答案:————
10.[单选题]下列哪个选项的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{ }
    正确答案:————
11.[单选题]顺序执行下列程序语句后,则b的值是
String a="Hello";
String b=a.substring(0,2);
    A.Hello
    B.hello
    C.Hel
    D.null
    正确答案:————
12.[单选题]以下代码的输出结果是什么?
class Foo{
public static void main(String args[]){
int x=4,j=0;
switch(x){
case 1:j++;
case 2:j++;
case 3:j++;
case 4:j++;
case 5:j++;
break;
default:j++;
}
System.out.println(j);
}
}
    A.1
    B.2
    C.3
    D.编译错误
    正确答案:————
13.[单选题]设有下面两个类的定义:
class  Person {                     
   long    id;     // 身份证号
   String  name;   // 姓名   
}                                            
class  Student  extends  Person {
           int  score;  // 入学总分
           int  getScore(){
      re
    A.包含关系
    B.继承关系
    C.关联关系
    D.无关系,上述类定义有语法错误
    正确答案:————
14.[单选题]请选择以下代码的正确的重载构造器。
class Happy {
Happy() {
}
}
    A.public void Happy(){}
    B.public Happy(int c){}
    C.protected Happy(){}
    D.void Happy(){}
    正确答案:————
15.[单选题]如果你有下面的类定义
abstract class Shape{
                abstract void draw();
}
请问,在试图编译下面的类定义时会发生什么情况?
class Square extends Shape{
}
    A.都可以成功编译
    B.Shpe可以编译,而Square不能
    C.Square可以编译,而Shape不能
    D.Shape和Square都不能编译
    正确答案:————
16.[单选题]下面的代码段中,执行之后i 和j 的值是什么?
int i = 1;
int j;
j = i++;
    A.1, 1
    B.1, 2
    C.2, 1
    D.2, 2
    正确答案:————
17.[单选题]下面程序的输出结果是什么?
String s= "ABCD";
s.concat("E");
s.replace('C','F');
System.out.println(s);
    A.编译错误,字符串是不可改变的
    B.ABFDE
    C.ABCDE
    D.ABCD
    正确答案:————
18.[单选题]下列程序段执行后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
    正确答案:————
19.[单选题]下面的语句的作用是:(     )。
    Vector  MyVector = new  Vector(100,50);
    A.创建一个数组类对象MyVector,有100个元素的空间,每个元素的初值为50。
    B.创建一个向量类对象MyVector,有100个元素的空间,每个元素的初值为50。
    C.创建一个数组类对象MyVector,有100个元素的空间,若空间使用完时,以50个元素空间单位递增。
    D.创建一个向量类对象MyVector,有100个元素的空间,若空间使用完时,以50个元素空间单位递增。
    正确答案:————
20.[单选题]已知表达式int m[] = {0, 1, 2, 3, 4, 5, 6 };
下面哪个表达式的值与数组下标量总数相等?
    A.m.length()
    B.m.length
    C.m.length()+1
    D.m.length+1
    正确答案:————
二、多选题:
21.[多选题]已知如下类定义:
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 ) { //... }
    正确答案:————
22.[多选题]已知如下类说明:
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
    正确答案:————
23.[多选题]已知如下定义:
String s = "story";
下面哪些表达式是合法的?
    A.s += "books";
    B.char c = s[1];
    C.int len = s.length;
    D.String t = s.toLowerCase();
    正确答案:————
24.[多选题]已知如下代码:
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.以上都不是
    正确答案:————
25.[多选题]给出下面的代码段:
public class Base{
int w, x, y ,z;
public Base(int a,int b)
{
x=a; y=b;
}
public Base(int a, int b, int c, int d)
{
//赋值 x=a, y=b
w=d;
z=c;
}
}
在代码说明//赋值 x=a, y=b处写入如下哪几行代码是正确的?
    A.Base(a,b)
    B.x=a,y=b;
    C.x=a;y=b;
    D.this(a,b);
    正确答案:————
26.[多选题]下面代码执行后的输出是什么?
outer: for(int i=0;i<3; i++)
inner: for(int j=0;j<2;j++)
{
if(j==1) continue outer;
System.out.println(j+ “ and “+i);
}
    A.0 and 0
    B.0 and 1
    C.0 and 2
    D.1 and 0
    E.1 and 1
    F.1 and 2
    G.2 and 0
    H.2 and 1
    I.2 and 2
    正确答案:————
27.[多选题]下面的哪些程序片断可能导致错误。
    A.String s="Gonewiththewind";
String t="good";
String k=s+t;
    B.String s="Gonewiththewind";
String t;
t=s[3]+"one";
    C.String s="Gonewiththewind";
String standard=s.toUpperCase();
    D.String s="homedirectory";
String t=s-"directory".
    正确答案:————
28.[多选题]针对下面的程序,那些表达式的值是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;
    正确答案:————
29.[多选题]已知如下代码:
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.什么都不输出
    正确答案:————
30.[多选题]选择所有有效的构造函数。
class Happy {
}
}
    A.public void Happy(){}
    B.public Happy(int c){}
    C.protected Happy(){}
    D.public int Happy(){}
    E.void Happy(){}
    正确答案:————
奥鹏作业答案
奥鹏东北大学作业

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

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

本版积分规则

精彩推荐

    明星用户

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

    GMT+8, 2024-4-26 00:46