楼主: NicklX
跳转到指定楼层
上一主题 下一主题
收起左侧

[讨论]UC Berkeley EECS 61B: Data Structures & Algorithms in Java

🔗
jby1797 2014-1-13 10:03:22 | 只看该作者
全局:
小K 发表于 2014-1-13 09:55
61B midterm 只看见答案没看见题目,这个哪里有?

我觉得midterm或者final题目都不会放出来吧。
我看过的公共课或者校内课的网页都没有。
可能是每年的题目有重复?
我们学校也是大力封锁各种试题的
回复

使用道具 举报

🔗
modifiedname 2014-1-13 10:05:54 | 只看该作者
全局:
rsun 发表于 2014-1-12 21:03
我觉得midterm或者final题目都不会放出来吧。
我看过的公共课或者校内课的网页都没有。
可能是每年的题 ...

哦好吧。。。本来还想考察一下自己学的如何的 :(
回复

使用道具 举报

🔗
modifiedname 2014-1-13 12:51:52 | 只看该作者
全局:
对了,学完61b还想继续用java做具体的事情,而不是另外学一门语言的话,怎么比较好呢?
继续上课,还是开始刷题目,or others?
回复

使用道具 举报

🔗
jby1797 2014-1-13 22:52:10 | 只看该作者
全局:
小K 发表于 2014-1-13 10:05
哦好吧。。。本来还想考察一下自己学的如何的 :(

偶然看到课程介绍里有这么一句话,貌似试卷网上没有但是可以在berkeley的书店买到?
如果是在国内,能买到的书,,几乎是必然有电子版啊
You should also buy the class reader, available at Vick Copy at 1879 Euclid, near Hearst. The bulk of the reader is old CS 61B exams, which will not be provided online (though the solutions are). By far the best way to study for the exams is to try the old ones. The remainder of the reader is information on using the compiler, debugger, and editor.
回复

使用道具 举报

🔗
modifiedname 2014-1-16 14:22:19 | 只看该作者
全局:
求讨论,我不确定我答案是对的

http://www.cs.berkeley.edu/~jrs/61b/lab/lab5/readme

  ((Superclass) subclassvariable).method();
我以为可以调用Super class的方法,但是居然不是的。。。为啥?
some code here, 求能人给看看啊啊啊
这个例子里面,没有什么办法能把Array of a superClass cast 成为 Array of subClass,我漏掉了什么吗?


  1. // Part I:  Assignments and Casting (1 point)
  2. // ------------------------------------------
  3. // Let Y be a subclass of X, and let y and x be variables of classes Y and X
  4. // respectively.  From lecture, you know that the assignment "x = y" is valid, but
  5. // the assignment "y = (Y) x" requires a cast to compile, and will cause a
  6. // run-time error if x references an object that isn't a Y.

  7. // What about arrays of objects?  Suppose xa is an array of X's, and ya is an
  8. // array of Y's.




  9. class X{  //Animal
  10.         protected int a = 1;
  11.         public int aa(){return (1);}
  12. }

  13. class Y extends X{ //Dog
  14.         protected int a = 2;
  15.         public int aa(){return(2);}
  16. }

  17. class Z extends X{ //Cat
  18.         protected int a = 3;
  19.         public int aa(){return(3);}
  20. }

  21. class testClass{
  22.         public static void main(String[] args){
  23.                 X x = new X();
  24.                 Y y = new Y();

  25.                 x = y;
  26.                 y = (Y) x;

  27.                 X[] xa = new X[5];
  28.                 Y[] ya = new Y[3];

  29. // (a)  At compile-time, can we assign xa to ya, and vice versa?  When is a cast
  30. //      required?
  31. // can assign Dog to Animal, but not vice versa, without casting
  32.                 xa = ya;

  33.                 X[] xa2 = new X[2];
  34.                 Y[] ya2 = new Y[3];

  35. // (b)  At run-time, if ya references an array of Y's, can we assign it to xa?
  36. //      Can we then assign it back from xa to ya?
  37.                 // Yes can assign Array of Dogs to Animals,  then assign back is also ok
  38.                 // ya2 = (Y[]) xa2; // can compile, run time error, can't assign animals as dogs.
  39.                 xa2[0] = new Y();
  40.                 xa2[1] = new Y();
  41.                 // ya2 = (Y[]) xa2; // still doesn't work, same run time error
  42.                 xa2 = ya2;

  43.                 X[] za = new X[2]; // array of animals
  44.                 // za[0] = new Z(); // this can be non assigned
  45.                 za[1] = new Z();
  46. // (c)  If xa references an array of X's (that are not Y's), can we assign it to
  47. //      ya?  Can we then assign it back from ya to xa?  Does it make a difference
  48. //      if the array of type X[] references objects that are all of class Y?  Why
  49. //      do you think this is the case?


  50.                 // ya = (y[]) za; // run time error!! can not cast cats to dogs

  51.                 za = new X[2];
  52.                 za[0]=new Y();
  53.                 za[1]=new Y();

  54.                 // ya = (Y[]) za;// run time error!! can not cast cats to dogs
  55.         }
  56. }
复制代码
回复

使用道具 举报

🔗
modifiedname 2014-1-16 14:24:36 | 只看该作者
全局:
(b)  Define a variable whose static type is the superclass and which references
     an object of the superclass (but not the subclass).  If we cast the
     variable to the subclass type before calling the method, does Java call
     the superclass method or the subclass method?
可是这个不能cast啊。。。
回复

使用道具 举报

🔗
modifiedname 2014-1-16 15:23:15 | 只看该作者
全局:
from outside sub class, there is no way to access super class methods, without a special method of sub class written just to access super class methods. ------ is this right? 所以无论怎么cast, methods都只按本来的type而不是cast以后的type??
回复

使用道具 举报

🔗
modifiedname 2014-1-16 15:49:32 | 只看该作者
全局:
这么简单一个lab5还做了两小时我会承认吗。。。。。。但是终于弄明白了真好~~~
回复

使用道具 举报

🔗
jaly50 2014-5-8 10:45:02 | 只看该作者
全局:
小K 发表于 2014-1-16 15:49
这么简单一个lab5还做了两小时我会承认吗。。。。。。但是终于弄明白了真好~~~

K姐
我现在也在跟这个课
我看到Lab1 里面写的 还要ta check off...还要注册什么账号
怎么感觉lab这种作业。。我们好像没有权限做似的

求解
lab能跟么?有其他入口?
回复

使用道具 举报

🔗
autocrat0124 2016-4-19 09:01:24 | 只看该作者
全局:
求问这个课的作业是在Linux系统完成的吗? 还是说windows上安装Java也可以?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号
隐私提醒:
  • ☑ 禁止发布广告,拉群,贴个人联系方式:找人请去🔗同学同事飞友,拉群请去🔗拉群结伴,广告请去🔗跳蚤市场,和 🔗租房广告|找室友
  • ☑ 论坛内容在发帖 30 分钟内可以编辑,过后则不能删帖。为防止被骚扰甚至人肉,不要公开留微信等联系方式,如有需求请以论坛私信方式发送。
  • ☑ 干货版块可免费使用 🔗超级匿名:面经(美国面经、中国面经、数科面经、PM面经),抖包袱(美国、中国)和录取汇报、定位选校版
  • ☑ 查阅全站 🔗各种匿名方法

本版积分规则

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