- 博客(116)
- 资源 (10)
- 收藏
- 关注
原创 test9.15
abstract class Flower{void f(){};void g(){};}class Lily extends Flower{void f(){System.out.println("f()");};void g(){System.out.println("g()");};void h(){System.out.println("h()");}}pu
2015-09-30 21:30:43 186
原创 test9.14
interface Port1{void f();void g();}interface Port2{void f();void g();}interface Port3{void f();void g();}interface Port extends Port1,Port2,Port3{void h();}class Flower{}class Lily exten
2015-09-30 21:25:44 239
原创 test9.13
interface Portbase{void f();}interface Portone extends Portbase{void f();}interface Porttwo extends Portbase{void f();}interface Portthree extends Portone,Porttwo{void f();}class Face implemen
2015-09-30 20:48:15 212
原创 test9.12
interface CanFight{void fight();}interface CanSwim{void swim();}interface CanFly{void fly();}interface CanClimb{void climb();}class ActionCharacter{public void fight(){}}class Hero exten
2015-09-30 20:28:50 270
原创 test9.10
我把原来的程序删除了一部分,使得题目的目的更加明确,删掉的有adjust()和String toString()如果自己添加进去也可,有一点是String toString()不能写到接口里面enum Note{MIDDLE_C,C_SHARP,B_FLAT;}interface Playable{void play(Note n);}class Wind implements
2015-09-30 10:49:36 233
原创 test9.9
把instrument 改为抽象类就可以了enum Note{MIDDLE_C,C_SHARP,B_FLAT;}abstract class Instrument{abstract void play(Note n); abstract void adjust();}class Wind extends Instrument{void play(Note n){S
2015-09-30 10:39:26 224
原创 test9.8
interface Fastfood{void feature();}class Meal implements Fastfood{public void feature(){System.out.println("Abundant");}Meal(){System.out.print("Meal() ");}}class Bread implements Fastfood{
2015-09-30 10:33:26 210
原创 test9.7
第六题没什么难度,当你在导出类中重写基类方法,前面如果不带public 系统会报错,意思就是说,人家原来是public 你现在也要写public,那么就可以知道基类默认抽象方法是公开的,第七题程序如下interface Rodent{public void apperence();}class Mouse implements Rodent{public void appere
2015-09-30 10:17:29 200
原创 test9.5
import java.util.*;interface Lily{void print();void show();void name(String s);}class Flower implements Lily{public void print(){System.out.println("Hello Java !");}public void show(){
2015-09-30 10:08:32 235
原创 test9.4
这个中文翻译的真实太费解了,参照标准答案才搞明白,下边是程序,其中注释部分是可替代内容,可以用注释内容代替它左边的那一句,运行结果相同abstract class Lily{} //{abstract public void f();}class Flower extends Lily{public void f(){System.out.println("Flower.f()
2015-09-30 09:29:00 257
原创 test9.3
test9.2很简单,9.3的意思说的有点拐弯抹角,但是细细分析写出来程序,然后运行结果却是让人惊奇abstract class Base{public abstract void print();Base(){print();}}public class Test3 extends Base{private int num=5;public void prin
2015-09-30 08:53:56 281
原创 test9.1
把Rodent 编程一个抽象类,内部的方法也变成抽象方法abstract class Rodent{public abstract void apperence();}class Mouse extends Rodent{public void apperence(){System.out.println("It runs fast");}}class Hamster
2015-09-30 08:35:21 338
原创 test8.17
因为Tricycle没有balance()函数,向下转型后Tricycle对象调用balance()会报错class Cycle{Cycle(){System.out.println("Cycle constructor");}}class Unicycle extends Cycle{Unicycle(){System.out.println("Unicycle construc
2015-09-29 20:57:30 265
原创 test8.16
class Alertstatus{public void status(){}}class Red extends Alertstatus{public void status(){System.out.println("Red");}}class Green extends Alertstatus{public void status(){System.ou
2015-09-29 20:40:13 220
原创 test8.15
class Glyph{void draw(){System.out.println("Glyph.draw()");}Glyph(){System.out.println("Glyph() before draw()");draw();System.out.println("Glyph() after draw()");}}class RoundGlyph ext
2015-09-29 17:34:52 291
原创 test8.14
class Rodent{private int refcount=0;public Rodent(){System.out.println("Rodent");}public void addRef(){refcount++;}public void show(){System.out.println("Reference = "+refcount);}}class Mo
2015-09-29 16:49:31 202
原创 test8.13
遗憾的是,没有运行处任何的finalize()结果,我觉得自己的程序也没有问题呀,不明白原因。看了别人的经验以后才知道System.gc()并不能保证finalize()壹鼎之星,因为System.gc()只是完成了通知任务,并不是强制执行。class Shared{private int refcount=0;private static long counter=0;pri
2015-09-29 16:24:48 247
原创 test8.12
这一题想让我们验证初始化步骤显示顶层基类,然后逐次到下层子类class Rodent{Rodent(){System.out.println("Rodent()");}public void apperence(){System.out.println("It has four feet");}}class Mouse extends Rodent{Mouse(){Syst
2015-09-29 15:08:15 226
原创 test8.11
这个题目真实有点boringclass Meal{Meal(){System.out.println("Meal()");}}class Bread{Bread(){System.out.println("Bread()");}}class Cheese{Cheese(){System.out.println("Cheese()");}}class Pick
2015-09-29 14:58:55 387
原创 学java 的感受
从买来java书有正好十天,才看到一百多页,这一本大块头要看到何年何月,有点捉急啊。 之前把C++看了一遍,那时的心情跟现在一样每天书书书,哎,不过java没有C++那么难熬,起码乐趣多一点。 虽然说编程语言相通,但是每一种都有自己的优势,所以不能仅限于一种,这是我的感受,之前看到同学用java做了一个应用软件安到自己手机上,好羡慕,我也弄来一本java实例的书,希望
2015-09-26 19:58:46 373
原创 test8.10
class Flower{public void show(int i){System.out.println("we have "+i+" "+color()+" flower");}public String color(){return "white";}}public class Lily extends Flower{@Override public String c
2015-09-26 19:41:24 202
原创 test8.9
class Rodent{public void apperence(){System.out.println("It has four feet");}}class Mouse extends Rodent{@Override public void apperence(){System.out.println("It runs fast");}}class Hamste
2015-09-26 19:17:00 287
原创 test8.7 &8.8
enum Note{MIDDLE_C,C_SHARP,B_FLAT;}class Instrument{void play(Note n){System.out.println("Instrument.play+ "+n);} void adjust(){System.out.println("Adjusting Instrument");} public String
2015-09-26 17:43:23 272
原创 test8.6
enum Note{MIDDLE_C,C_SHARP,B_FLAT;}class Instrument{void play(Note n){System.out.println("Instrument.play+ "+n);} void adjust(){System.out.println("Adjusting Instrument");} public String
2015-09-26 17:36:46 222
原创 test8.5
在Cycle修改了构造函数,并增加一个wheels()函数,然后Unicycle Bicycle Triangle cycle的构造函数全部随之修改,最后根据前面的修改变化ride()就可以出来题目要求的效果class Cycle{private int n;Cycle(int i){n=i;System.out.println("Cycle constructor");}publ
2015-09-26 16:54:45 209
原创 test8.4
这一题出的没什么意思,仅仅是让你在Shapes下边定义一个新的Shape对象,然后调用Shanpe class下包含的函数,跟老的s[0,1,2...9】做比较,输出效果完全一样,没什么区别import java.util.Random;class Shape{public void draw(){}public void erase(){}public void sh
2015-09-26 16:40:57 300
原创 test8.3
import java.util.Random;import javax.swing.plaf.synth.SynthScrollPaneUI;class Shape{public void draw(){}public void erase(){}public void show(){System.out.println("Shape.show()");}}cla
2015-09-26 16:27:36 221
原创 test8.2
题目的意思就是在三个子类中,凡是有名字为draw() erase()的函数前面就要叫上@Override实现子类函数对父类相同函数的覆盖import java.util.*;class Shape{public void draw(){}public void erase(){}}class Circle extends Shape{@Override public
2015-09-26 15:38:41 324
原创 test8.1
题目的意思是构造一个函数ride(Cycle c)但是在使用ride()的是偶给它的参数c是Unicycle Bicycle 或者Tricycle而不是直接的Cycle,此时的参数可以完成向上转换,即编程Cycle对象,根据输出结果中出现的Cycle()构造函数知道确实出现了向上转型class Cycle{Cycle(){System.out.println("Cycle construc
2015-09-26 15:05:53 209
原创 test7.24
class Insect{private int i=9;protected int j;Insect(){System.out.println("i= "+i+" j= "+j);j=39;}private static int x1=printInt("Static Insect.x1 initialized"); static int printInt(String
2015-09-26 11:58:57 259
原创 test7.23
class Flower{Flower(){System.out.println("Flower");}static int num=9;}public class Lily extends Flower{Lily(){System.out.println("Lily");}public static void main(String[] args) {//Lily l
2015-09-26 11:34:29 234
原创 test7.22
final class Flower{void f(){System.out.println("Flower.f()");}}public class Lily extends Flower{ public static void main(String[] args) {Lily lily=new Lily();}}提示错误,意思说我们不能集成一个fina
2015-09-26 10:38:17 272
原创 test7.21
class Flower{public final void f(){System.out.println("Flower.f()");}private void g(){System.out.println("Flower.g()");}public void h(){System.out.println("Flower.h()");}}public class Lily
2015-09-26 10:09:03 212
原创 test7.20
经过尝试我发现一个规律:如果你想在子类中覆盖父类的同一个函数,那么两个函数都必须是public而且不能是final否则,@Override会报错,因为对于private或者final 已经是父类特有的函数,不向外提供接口。子类根本无法使用它,无需覆盖。 这一题我把OverridePrivate的g()变成public然后在OverridePrivate2的g()可以使用@Override.
2015-09-26 09:58:56 269
原创 test7.19
class Paper{private final int n;Paper(int i){n=i;System.out.println("In Paper :"+n);}}public class Test19 {private String size;private final Paper p;Test19(){size="Round";p=new Paper(3
2015-09-26 09:04:28 243
原创 test7.18
public class Test18 {private final int vone=12;private static final int V_TWO=54;public static void main(String[] args) {vone=90;V_TWO=80;//first equation is invalid,but second isn't}}
2015-09-26 09:03:25 215
原创 test7.17
class Amphibian{private int num;private String shape;Amphibian(int n,String s){num=n;shape=s;}static void display(Amphibian am){System.out.println("In Amphibian ");}}public class Frog ex
2015-09-25 20:56:14 251
原创 test7.16
class Amphibian{private int num;private String shape;Amphibian(int n,String s){num=n;shape=s;}static void display(Amphibian am){System.out.println(am.num+" "+am.shape);}}public class Fro
2015-09-25 20:51:31 259
原创 test7.15
class Paper{private int number;Paper(int n){number=n;}protected void count(){System.out.println("We total have "+number);}}public class Test15 extends Paper{Test15(int i){super(i);}publi
2015-09-25 19:33:58 245
原创 test7.14
class Engine{public void start(){}public void rev(){}public void stop(){}public void service(){System.out.println("Service ");}}class Wheel{public void inflate(int psi){}}class Window{
2015-09-25 19:19:02 271
stm32 CAN1 CAN2 loopback
2018-05-18
stm32 TIM input capture and create PWM wave
2018-04-29
Configure Eclipse for STM32 development
2017-12-09
LSD a line detection algorithm
2017-10-22
数字图像处理 冈萨雷斯 中文第二版
2015-11-26
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人