一副牌Deck有52张扑克Card组成(不含王牌),每张牌有自己的牌型suit(用char类型)和点数rank(用String类型),补充完整下面的类的定义。public class Card {//1//2public Card( ) {//3this.suit = suit; this.rank = rank;}public String toString() { return suit+rank; }public static void main(String[] args){Card c=new Card('红',"10");System.out.println(c);}}
举一反三
- class Card{}下列属于Card类的构造方法的是()? A: private Card(){} B: public void Card(){} C: public Card(){} D: Card(){}
- 中国大学MOOC: 下列代码中构造方法的返回类型是()public class Village { Village () { System .out .println(“hiding in Village”) ; } public static void main( String args [ ]) { Village c =new Village ( ) ;}class Village { public static void main( String args [ ]) { Village c =new Village ( ) ; } Village () { System .out .println(“hiding in Village”) ; } }
- public class Test { public static void main(String[] args) { String s1 = "abc"; String s2 = new String ("abc"); System.out.println(s1 == s2); } } 程序运行结果是
- 对于class Card{}类,下列不属于Card类的构造方法的是( )。 A: Card(){} B: public Card(){} C: public void Card(){} D: private Card(){}
- 以下可执行main函数定义正确的是(<br/>)。<br/>A. <br/>public main(String[] A: public<br/>static void main(String[] args){} B: public<br/>void main(String args){} C: public<br/>static void main(String args){}