2020 面向对象程序设计(基于Java)(华东师范大学) 最新满分章节测试答案
- 【作业】第三章 Java类基础知识 第三章 Java类基础知识 作业
- 第五章 继承、接口和抽象类 第五章 单元测验
- 第六章 static、final和常量设计(续) 期中练习
- 第九章 Java异常和异常处理 第九章 Java异常和异常处理 测验
- 第四章 面向对象和类 (续) 前四章 单元测验
- 【作业】第二章 Java环境搭建和程序初体验 第二章作业 单步调试程序
- 第六章 static、final和常量设计 第六章 static和final测验
- 【作业】第七章 package、import和classpath 第七章 package、import和classpath 作业
- 【作业】第八章 Java常用类 第八章 Java常用类 作业
- 【作业】第十章 Java数据结构 第十章 Java数据结构 作业
- 【作业】第十一章 Java文件读写 第十一章 Java文件读写 作业
- 【作业】第四章 面向对象和类 第四章 面向对象和类 第一次作业
本答案对应课程为:点我自动跳转查看
本课程起止时间为:2020-07-06到2020-08-02
本篇答案更新状态:已完结
【作业】第三章 Java类基础知识 第三章 Java类基础知识 作业
1、 问题:请实现程序输出以下55数字方格。1 2 3 4 56 7 8 9 1011 12 13 14 1516 17 18 19 2021 22 23 24 25需要在main函数的输入参数中设置5,输出55的数字方格。如果是输入7,则是7*7的数字方格。需要提交代码、(Eclipse)设置参数截图、(Eclipse)运行结果截图。
评分规则: 【 正确设置输入参数,10分。完成程序功能,70分。
】
2、 问题:请实现程序输出以下星塔。 * * * 需要在main函数的输入参数中设置5,输出5层星塔。如果是输入7,则是7层星塔。假设输入参数都是奇数,且都大于等于5,小于等于11。需要提交代码、(Eclipse)设置参数截图、(Eclipse)运行结果截图。
评分规则: 【 正确完成单独一个参数,如参数是5的情况,15分。可以根据参数自适应匹配,5分。
】
第五章 继承、接口和抽象类 第五章 单元测验
1、 问题:现有 public class Parent{ public void change (int x){ } } public class Child extends Parent{ //覆盖父类change方法 }下列哪个声明是正确的覆盖了父类的change方法?
选项:
A:protected void change (int x){}
B:public void change(int x, int y){}
C:public void change (int x){}
D:public void change (String s){}
答案: 【public void change (int x){}】
2、 问题: class Ca{ int num = 1; Ca(int num){ this.num = num; System.out.print(this.num); }}class Cb extends Ca{ int num = 2; Cb(int num) { this.num = num; System.out.print(num); } public static void main(String[] args) { Ca a = new Cb(5); }} 运行代码,程序输出结果为:
选项:
A:15
B:52
C:51
D:编译报错
答案: 【编译报错】
3、 问题:下面关于继承的叙述正确的是()
选项:
A:Java中一个类只能实现一个接口
B:Java类中只允许单一继承
C:Java中一个类不能同时继承一个类和实现一个接口
D:Java中一个类可继承于多个类
答案: 【Java类中只允许单一继承】
4、 问题:给定下列程序,请选出正确结果。class Cat { Cat (int c) { System.out.print (“cat”+c+” “); } }class SubCat extends Cat { SubCat (int c){ super (5); System.out.print (“cable”); } SubCat() { this (4); } public static void main (String [] args) { SubCat s= new SubCat(); }}
选项:
A:cat5
B:cable
C:cat5 cable
D:cable cat5
答案: 【cat5 cable】
5、 问题:下列程序的输出是()。class Other{ public Other () { System.out.print(“Other!”); } } public class Driver1 extends Other { public static void main( String[] args ) { new Driver1(); new Other (); } }
选项:
A:Other!
B:Other!Other!
C:Other!Other!Other!
D:编译出错
答案: 【Other!Other!】
6、 问题:请选出以下程序的输出结果class A { public void func1() { System.out.println(“A func1 is calling”); } public void func2() { func1(); }}class B extends A { public void func1() { System.out.println(“B func1 is calling”); } public void func3() { System.out.println(“B func3 is calling”); }}class C { public static void main(String[] args) { A a = new B(); a.func1(); a.func2(); a.func3(); } }
选项:
A:A func1 is callingB func3 is calling
B:B func1 is callingB func3 is calling
C:A func1 is callingA func1 is callingB func3 is calling
D:编译错误
答案: 【编译错误】
7、 问题:请选出以下程序的输出结果public class Child extends People { People father; public Child(String name) { System.out.print(3); this.name = name; father = new People(name + “:F”); } public Child() { System.out.print(4); } public static void main(String[] args) { new Child(“Alice”); }}class People { String name; public People() { System.out.print(1); } public People(String name) { System.out.print(2); this.name = name; }}
选项:
A:123
B:132
C:32
D:312
答案: 【132】
8、 问题:请选出正确答案class Parent { String one, two; public Parent(String a, String b){ one = a; two = b; } public void print(){ System.out.println(one); }}public class Child extends Parent { public Child(String a, String b){ super(a,b); } public void print(){ System.out.println(one + ” to ” + two); } public static void main(String arg[]){ Parent p = new Parent(“south”, “north”); Parent t = new Child(“east”, “west”); p.print(); t.print(); }}
选项:
A:Cause error during compilation.
B:south to northeast to west
C:south to northeast
D:southeast to west
答案: 【southeast to west】
9、 问题:请选择正确的输出结果class Guy { public Guy(){ System.out.print(“111,”); }}class Cowboy extends Guy { public Cowboy(){ System.out.print(“222,”); }}class Wrangler extends Cowboy { public Wrangler(){ System.out.print(“333,”); }}public class Greeting2 { public static void main(String[] args) { Guy g1 = new Guy(); Guy g2 = new Cowboy(); Guy g3 = new Wrangler(); }}
选项:
A:111,222,333,
B:111,111,222,222,333,
C:111,111,222,111,222,333,
D:编译错误
答案: 【111,111,222,111,222,333,】
10、 问题:给定以下程序class Pencil { public void write (String content){ System.out.println( “Write”+content); }}class RubberPencil extends Pencil{ public void write (String content){ System.out.println(“Rubber Write”+content); } public void erase (String content){ System.out.println( “Erase “+content); }}执行下列代码的结果是哪项?Pencil p=new Pencil();(( RubberPencil) p).write(“Hello”);
选项:
A:Write Hello
B:Rubber Write Hello
C:编译失败
D:运行时抛出异常
答案: 【运行时抛出异常】
第六章 static、final和常量设计(续) 期中练习
1、 问题:有如下类定义:public class ClassAndVariables{ public static int x = 8; public int y = 9; }执行如下代码:ClassAndVariables a = new ClassAndVariables();ClassAndVariables b = new ClassAndVariables();a.y = 5;b.y = 6;a.x = 1;b.x = 2;则a.y, b.y, a.x, b.x的值分别为:
选项:
A:5, 6, 1, 2
B:6, 6, 1, 2
C:5, 6, 2, 2
D:6, 6, 2, 2
答案: 【5, 6, 2, 2】
2、 问题:请阅读以下程序,并写出结果public class ArgumentPassing { public static void changeValue(int a) { a = 10; } public static void changeValue(String s1){ s1 = “def”; } public static void changeValue(StringBuffer s1) { s1.append(“def”); } public static void main(String[] args) { int a = 5; String b = “abc”; StringBuffer c = new StringBuffer(“abc”); changeValue(a); changeValue(b); changeValue(c); System.out.print(a); System.out.print(b); System.out.print(c); }}
选项:
A:5abcabc
B:10abcabc
C:10defdef
D:5abcabcdef
答案: 【5abcabcdef】
3、 问题:下列关于构造方法的叙述中,错误的是
选项:
A:Java语言规定构造方法名与类名必须相同
B:Java语言规定构造方法没有返回值,但不用void声明
C:Java语言规定构造方法不可以重载
D:Java语言规定构造方法只能通过new自动调用
答案: 【Java语言规定构造方法不可以重载】
4、 问题:关于以下程序段,正确的说法是()。 String s1= “abc” + “def”; //1 String s2= new String(s1); //2 if (s1==s2) //3 System.out.println(“= = succeeded”); //4 if (s1.equals(s2)) //5 System.out.println(“.equals() succeeded”); //6
选项:
A:行4与行6都将执行
B:行4执行,行6不执行
C:行6执行,行4不执行
D:行4、行6都不执行
答案: 【行6执行,行4不执行】
5、 问题:请阅读以下程序,并写成结果。class Father{ public void hello() { System.out.println(“Father says hello.”); }}public class Child extends Father{ public void hello() { System.out.println(“Child says hello”); } public static void main(String[] a) { Child foo = new Child(); //foo.hello(); Father foo2 = (Father) foo; //foo2.hello(); Child foo3 = (Child) foo2; //foo3.hello(); System.out.println(foo==foo2); System.out.println(foo==foo3); }}
选项:
A:true true
B:true false
C:false true
D:false false
答案: 【true true】
6、 问题:运行如下程序,输出结果是()。StringBuffer sb = new StringBuffer(“good morning!”);String sub = sb.substring(0, 8);System.out.println(sub);System.out.print(“/”);char c = sb.charAt(6);System.out.println(c);
选项:
A:good mor/o
B:good morn/o
C:good morn/m
D:good mor/o
答案: 【good mor/o】
7、 问题:如下所示的Test类的Java程序中,共有几个构造方法()。 public class Test{ private int x; public Test(){} public void Test(int i){ this.x=i; } public Test(String str){} }
选项:
A:0
B:1
C:2
D:3
答案: 【2】
8、 问题:下面代码的运行结果为:()public class Foo { static String s; public static void main (String[]args) { System.out.println (“s=” + s); }}
选项:
A:代码得到编译,并输出“s=”
B:代码得到编译,并输出“s=null”
C:由于String s没有初始化,代码不能编译通过
D:代码得到编译,但捕获到 NullPointException异常
答案: 【代码得到编译,并输出“s=null”】
9、 问题:已知如下代码:( )public class Test{ public static void main(String arg[] ) { int i = 5; do{ System.out.print(i); }while(-i>5); System.out.print(“finished”); }}执行后的输出是什么?
选项:
A:5finished
B:4
C:6
D:finished
答案: 【5finished】
10、 问题:Given:abstract class Bar { public int getNum() { return 38; }}public abstract class AbstractTest { public int getNum() { return 45; } public static void main(String[] args) { AbstractTest t = new AbstractTest() { public int getNum() { return 22; } }; Bar f = new Bar() { public int getNum() { return 57; } }; System.out.println(f.getNum() + ” ” + t.getNum()); } }What is the result?
选项:
A:57 22
B:45 38
C:45 57
D:An exception occurs
答案: 【57 22】
11、 问题:public class Child extends People { People father; public Child(String name) { System.out.print(3); this.name = name; father = new People(name + “:F”); } public Child() { System.out.print(4); } public static void main(String[] args) { new Child(“Alice”); } } class People { String name; public People() { System.out.print(1); } public People(String name) { System.out.print(2); this.name = name; }}
选项:
A:32
B:132
C:123
D:1234
答案: 【132】
12、 问题:现有: class Guy{ String greet(){ return “hi “; }} class Cowboy extends Guy{ String greet(){ return “howdy “; }} class Wrangler extends Cowboy{ String greet(){ return “ouch! “; } } class Greetings2 { public static void main (String [] args) { Guy g=new Wrangler(); Guy g2=new Cowboy(); Wrangler w2=new Wrangler(); System.out.print(g.greet()+g2.greet()+w2.greet()); } }结果是什么?
选项:
本文章不含期末不含主观题!!
本文章不含期末不含主观题!!
支付后可长期查看
有疑问请添加客服QQ 2356025045反馈
如遇卡顿看不了请换个浏览器即可打开
请看清楚了再购买哦,电子资源购买后不支持退款哦