奥鹏易百

 找回密码
 立即注册

扫一扫,访问微社区

QQ登录

只需一步,快速开始

帮助中心知识拓展客服QQ 515224986
查看: 331|回复: 0

东北大学19春学期《JAVA语言程序设计Ⅰ》在线作业1(含答案)

[复制链接]

1万

主题

1

回帖

2万

积分

论坛元老

积分
29370
发表于 2019-3-17 19:13:52 | 显示全部楼层 |阅读模式
扫码加微信
19春学期《JAVA语言程序设计Ⅰ》在线作业1

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

一、单选题:
1.[单选题]下列代码的执行结果是
public class Test
{     public int aMethod()
      {
           static int i=0;
           i++;
           System.out.println(i);
      }
      public static void main(String args[])
      {
           Test test = new Test();
    A.编译错误
    B.0
    C.1
    D.运行成功,但不输出
    正确答案:——A——
2.[单选题]下面程序的输出结果是什么?
public static void main(String args[])
{
int a=10;
int b=20;
if(a=b)
System.out.println("Not Equal");
else
System.out.println("Equal");
}
    A.Equal
    B.Not Equal
    C.编译错误
    D.运行时将抛出异常
    正确答案:——C——
3.[单选题]Person, Student 和Teacher 都是类名。这些类有以下继承关系。
Person
|
--------------------
|             |
Student    Teacher
并且在Java源代码中有如下表达式:
Person p = new Student();
如下哪个语句是正确的?
    A.这条语句是合法的
    B.这条语句是不合法的
    C.编译时出错
    D.编译正确但运行时出错
    正确答案:——A——
4.[单选题]已知如下的命令执行
java MyTest a b c
请问哪个语句是正确的?
    A.args[0] = "MyTest a b c"
    B.args[0] = "MyTest"
    C.args[0] = "a"
    D.args[1]= 'b'
    正确答案:————
5.[单选题]下列类头定义中,错误的是( )。
    A.class x
   { .... }
    B.public x extends y
   { .... }
    C.public class x extends y
   { .... }
    D.class x extends y implements y1
   { .... }
    正确答案:————
6.[单选题]下面程序的输出结果是什么?
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
    正确答案:————
7.[单选题]下列哪个选项的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{ }
    正确答案:————
8.[单选题]下面程序的输出结果是什么?
String s= "ABCD";
s.concat("E");
s.replace('C','F');
System.out.println(s);
    A.编译错误,字符串是不可改变的
    B.ABFDE
    C.ABCDE
    D.ABCD
    正确答案:————
9.[单选题]给出如下代码:
class Test{
  private int m;
  public static void fun() {
    // some code...
  }
}
如何使成员变量m被函数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
    正确答案:————
10.[单选题]设有下面的一个类定义:
   class  AA {
     static  void  Show( ){ System.out.println("我喜欢Java!"); }
   }
   class  BB {  void  Show( ){ System.out.println("我喜欢C++!"); } }
若已经使用AA类创建对象a和BB类创建对象b,则下面哪一个方法调用是正确的:(     )
    A.a.Show( )
b.Show( )
    B.AA.Show( )
BB.Show( )
    C.AA.Show( )
b.Show( )
    D.a.Show( )
BB.Show( )
    正确答案:————
11.[单选题]下面程序的输出结果是什么?
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.运行时出现异常
    正确答案:————
12.[单选题]若有循环:
int x=5,y=20;
do{
    y-=x;
    x++;
  }while(++x<--y);则循环体将被执行( )。
    A.0次
    B.1次
    C.2次
    D.3次
    正确答案:————
13.[单选题]设有下面的两个类定义:
   class  AA {  
     void  Show(){ System.out.println("我喜欢Java!");
   }
   class  BB extends  AA {
     void  Show(){ System.out.println("我喜欢C++!");
   }
则顺序执行如下语句后输出结果为:(     )
     AA   a;          BB   b;
     a.Show();        b.Show();
    A.我喜欢Java!
我喜欢C++!
    B.我喜欢C++!
我喜欢Java!
    C.我喜欢Java!
我喜欢Java!
    D.我喜欢C++!
我喜欢C++!
    正确答案:————
14.[单选题]阅读下列代码后  
public class Person{  
int arr[]=new int[10];  
public static void main(String args[]){  
System.out.println(arr[1]);  
}  
}  
正确的说法是
    A.编译时将产生错误
    B.编译时正确,运行时将产生错误
    C.输出零
    D.输出空
    正确答案:————
15.[单选题]已知表达式int m[] = {0, 1, 2, 3, 4, 5, 6 };
下面哪个表达式的值与数组下标量总数相等?
    A.m.length()
    B.m.length
    C.m.length()+1
    D.m.length+1
    正确答案:————
16.[单选题]65. 已知有下列类的说明,则下列哪个语句是正确的?
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.f;
    正确答案:————
17.[单选题]设有下面两个类的定义:
class  Person {                     
   long    id;     // 身份证号
   String  name;   // 姓名   
}                                            
class  Student  extends  Person {
           int  score;  // 入学总分
           int  getScore(){
      re
    A.包含关系
    B.继承关系
    C.关联关系
    D.无关系,上述类定义有语法错误
    正确答案:————
18.[单选题]下列语句序列执行后,a的值是( )。
int a=13;
a%=a/5;
    A.3
    B.13
    C.1
    D.169
    正确答案:————
19.[单选题]下面语句返回的数据类型是什么?
(short)10/10.2*2;
    A.int
    B.double
    C.float
    D.short
    正确答案:————
20.[单选题]下列程序的功能是在监控台上每隔一秒钟显示一个字符串“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
    正确答案:————
二、多选题:
21.[多选题]你怎样从下面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]
    正确答案:————
22.[多选题]下面代码执行后的输出是什么?
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
    正确答案:————
23.[多选题]选择所有有效的构造函数。
class Happy {
}
}
    A.public void Happy(){}
    B.public Happy(int c){}
    C.protected Happy(){}
    D.public int Happy(){}
    E.void Happy(){}
    正确答案:————
24.[多选题]下面的哪些程序片断可能导致错误。
    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".
    正确答案:————
25.[多选题]针对下面的程序,那些表达式的值是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;
    正确答案:————
26.[多选题]已知如下代码:
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.以上都不是
    正确答案:————
27.[多选题]已知如下代码:
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.什么都不输出
    正确答案:————
28.[多选题]已知如下类说明:
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
    正确答案:————
29.[多选题]已知如下定义:
String s = "story";
下面哪些表达式是合法的?
    A.s += "books";
    B.char c = s[1];
    C.int len = s.length;
    D.String t = s.toLowerCase();
    正确答案:————
30.[多选题]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;
    正确答案:————
奥鹏作业答案
奥鹏东北大学作业
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2024-5-7 11:58

Powered by Discuz! X3.5

Copyright © 2001-2024 Tencent Cloud.

快速回复 返回顶部 返回列表