20172320 2017-2018-2 《Java程序设计》第四周学习总结

教材学习内容总结

1、类结构的定义和概念
2、利用实例数据建立对象状态的概念
3、可见修饰符
4、构造方法的结构和用途
5、软件开发活动的方式
6、类之间的关系
7、接口的用法
8、枚举型类的定义
9、方法重载

教材学习中的问题和解决过程

  • 问题1:Comparable接口的使用方式不是很懂
  • 问题1解决方案:在网上搜了很多篇博客,大多都写了很长的程序,用到的只有一点
    20172320 《程序设计与数据结构》第四周学习总结

代码调试中的问题和解决过程

  • 问题1:PP4.5中isAntique的编写
  • 问题1解决方案:因为涉及到讨论车是否在45年以上,要用到if-else语句,一开始很蒙蔽,看了下后面对应的内容才写出。布尔型在CarTest中的应用,刚开始也不会,问了同学后直接应用
    20172320 《程序设计与数据结构》第四周学习总结

  • 问题2:this的使用
  • 问题2解决方案:每次类中取名字很头疼,毕竟不能用一样的,看了第七章this后尝试用了一下,它提示错误,课上老师讲了后才发现自己的错误,应是this.name=name;我写成了name=this.name
  • ...

代码托管

上周考试错题总结

  • In Java a variable may contain
    A . a value or a reference
    B . a package
    C . a method
    D . a class
    E . any of the above
    在Java中,变量包含基本类型和引用类型

  • What happens if you attempt to use a variable before it has been initialized?
    A . A syntax error may be generated by the compiler
    B . A runtime error may occur during execution
    C . A "garbage" or "uninitialized" value will be used in the computation
    D . A value of zero is used if a variable has not been initialized
    E . Answers A and B are correct
    若是用一个未初始化的变量,编译器会产生一个语法错误,执行时可能运行错误
  • In Java, "instantiation" means
    A . noticing the first time something is used
    B . creating a new object of the class
    C . creating a new alias to an existing object
    D . launching a method
    E . none of the above
    实例化创建类的一个新对象
  • Which of the following will yield a pseudorandom number in the range [ -5, +5 ) given the following:
    Random gen = new Random( );
    A . gen.nextFloat( ) * 5
    B . gen.nextFloat( ) * 10 - 5
    C . gen.nextFloat( ) * 5 - 10
    D . gen.nextInt( ) * 10 - 5
    E . gen.nextInt(10) - 5
    nextFloat()的范围是[0,1),乘10再减5就是[-5,+5)
  • Consider the following two lines of code. What can you say about s1 and s2?
    String s1 = "testing" + "123";
    String s2 = new String("testing 123");
    A . s1 and s2 are both references to the same String object
    B . the line declaring s2 is legal Java; the line declaring s1 will produce a syntax error
    C . s1 and s2 are both references to different String objects
    D . s1 and s2 will compare "equal"
    E . none of the above
    s1输出的是testing123,s2输出testing 123
  • The String class' compareTo method
    A . compares two string in a case-independent manner
    B . yields true or false
    C . yields 0 if the two strings are identical
    D . returns 1 if the first string comes lexically before the second string
    E . none of the above
    若两个字符串一样,就会得到0;若第一个字符串在第二个后面出现,得-1;反之1
  • An API is
    A . an Abstract Programming Interface
    B . an Application Programmer's Interface
    C . an Application Programming Interface
    D . an Abstract Programmer's Interface
    E . an Absolute Programming Interface
    API是一个应用程序编程接口,它是为特定目的而构建的相关类的集合。它们通常驻留在类库中。
  • Consider the following enumeration
    enum Speed { FAST, MEDIUM, SLOW };
    A . The ordinal value of MEDIUM is 2
    B . The ordinal value of SLOW is 1
    C . The name of the Speed enumeration whose ordinal value is zero is FAST
    D . The name of the Speed enumeration whose ordinal value is one is SLOW
    E . None of the above
    枚举的序号从0开始,FAST对应的是0
  • These two ways of setting up a string yield identical results:

a) String string = new String("string");

b) String string = "string";
A . true
B . false
两个初始化内容都是“string”

  • These two ways of setting up a String yield identical results:

a) String string = "12345"

b) String string = 12345;
A . true
B . false
第二个不能编译,将会收到关于不兼容类型的语法错误提示

  • All the methods in the Math class are declared to be static.
    A . true
    B . false
    Math是一种静态方法
  • The names of the wrapper classes are just the names of the primitive data types, but with an initial capital letter.
    A . true
    B . false
    大多数类包装类是这样,int和char不是

    学习进度条

代码行数(新增/累积)博客量(新增/累积)学习时间(新增/累积)重要成长
目标5000行30篇400小时
第一周67/671/420/20
第二周328/3951/520/40
第三周523/8511/620/60
第四周1070/19211/720/80