class Person{
public Person(){
System.out.println(\ }
public Person(String s){ this();
System.out.println(\ } }
public class Who extends Person{ public Who(){
this(\ }
public Who(String s){ super(s);
System.out.println(\ }
public static void main(String args[]){ Who w = new Who(\ } }
5¡¢ÔĶÁÏÂÃæµÄ³ÌÐò£¬³ÌÐò±£´æÎªTest.java£º
1) public class Test 2) {
3) short mValue;
4) public static void main(String[] args) 5) {
6) int a = 32; 7) int b = 56;
8) Test os = new Test(a+b); 9) os.Show( ); 10) }
11) protected Test(short aValue) { mValue = aValue; } 12) public void Show( ) { System.out.println(mValue); } 13) }
ÉÏÃæµÄ³ÌÐò±àÒëÊÇ·ñ³É¹¦£¿Èç¹û±àÒë³ö´í£¬Ö¸³öÄÄÐгö´í£¬²¢ËµÃ÷ÀíÓÉ£»Èç¹û±àÒëÕýÈ·£¬ÔËÐнá¹ûÊÇʲô£¿
6¡¢ÔĶÁÏÂÃæµÄ³ÌÐò£º
class test {
public static void main(String[] args)
µÚ 17 Ò³ ¹² 48 Ò³
{
int i = 1; int All = 0; for (;i<=10;i++) {
if (i%6==0) break;
if(i%2==0) {i=i+2;continue;} All = All + i; }
System.out.println(All); } }
ÉÏÃæµÄ³ÌÐò±àÒëÊÇ·ñ³É¹¦£¿Èç¹û±àÒë³ö´í£¬Ö¸³öÄÄÐгö´í£¬²¢ËµÃ÷ÀíÓÉ£»Èç¹û±àÒëÕýÈ·£¬ÔËÐнá¹ûÊÇʲô£¿ 6
7¡¢ÔĶÁÏÂÃæµÄ³ÌÐò£º
1) public class test 2) {
3) public static void main(String argv[]) 4) {
5) Bird b = new Bird(); 6) b.Fly(3); 7) } 8) }
9) class Bird{
10) static int Type = 2;
11) private void Fly(int an_Type){ 12) Type = an_Type;
13) System.out.println(\14) } 15) }
ÉÏÃæµÄ³ÌÐò±àÒëÊÇ·ñ³É¹¦£¿Èç¹û±àÒë³ö´í£¬Ö¸³öÄÄÐгö´í£¬²¢ËµÃ÷ÀíÓÉ£»Èç¹û±àÒëÕýÈ·£¬ÔËÐнá¹ûÊÇʲô£¿
8¡¢Ð´³öÏÂÁгÌÐò´úÂëµÄÔËÐнá¹û£º public class Example{
String str=new String(\ char ch[]={'J','a','v', 'a'};
public static void main(String args[]){ Example ex=new Example(); ex.change(ex.str,ex.ch); System.out.println(ex.str);
System.out.println(new String(ex.ch)); }
µÚ 18 Ò³ ¹² 48 Ò³
}
public void change(String str,char ch[]){
str=\ch[0]= 'Y'; }
9¡¢ÔĶÁÏÂÃæµÄ³ÌÐòTestMonth.java£º public class TestMonth{
public static void main(String []args){ try{
int month=Integer.parseInt(args[0]); if(month<0||month>12){
throw new ArithmeticException(\ûÓÐ\Ô·Ý!\ }
System.out.println(\ÄúÊäÈëµÄÔ·ÝΪ\Ô·Ý\ }catch(ArrayIndexOutOfBoundsException e){ System.out.println(\ÇëÊäÈëÔ·ݣ¡\ }catch(ArithmeticException e){
System.out.println(\²¶»ñArithmeticExceptionÒì³£\ System.out.println(e.toString()); } } }
ÒÑÖªArrayIndexOutOfBoundsExceptionºÍArithmeticException¶¼ÊÇjava.lang.*ϵÄÒì³£À࣬±àÒëTestMonth.javaºó£¬ÓÃjava TestMonth 13µÄÔËÐнá¹ûÊÇʲô£¿
10¡¢Ð´³öÏÂÁгÌÐò´úÂëµÄÔËÐнá¹û£º
class userException extends Exception{ userException(){}
userException(String str){ super(str); } }
class MyException {
final static int ARRAY_MAX_LENGTH=10; void judge(int []a){ try{
if(a.length System.out.println(\Êý×éµÄ³¤¶ÈûÓг¬¹ý¹æ¶¨µÄ×î´óÖµ!\ } else{ throw new userException(\Êý×é¿ÉÄÜÔ½½ç£¡\ } }catch(userException e){ µÚ 19 Ò³ ¹² 48 Ò³ System.out.println(e.toString()); } finally{ System.out.println(\Í˳ö·µ»Ø£¡\ } } public static void main(String agrs[]){ try{ int a[]=new int[10]; MyException myE=new MyException(); myE.judge(a); }catch(Exception e){ System.out.println(e.toString()); } } } 11¡¢ÔĶÁÏÂÃæ´úÂëÆ¬¶Î£¬Ð´³öÊä³ö½á¹û¡££¨Èç¹û´úÂëÓÐ´í£¬Çëд³ö´íÎóÔÒò£© public class ExceptionExample { public static void main(String[] args) { int a = 8; int b = 2; int c = 0; try{ c = a/(b-2); System.out.println(\¼ÆËã½á¹û£º\ }catch(ArithmeticException arithmeticException) { System.out.println(\²¶»ñÁËÒ»¸öÁã³ýÒì³£\ }catch(Exception exception) { System.out.println(\²¶»ñÁËÒ»¸öÒì³£\ } } } 12¡¢ÔĶÁÏÂÃæ´úÂëÆ¬¶Î£¬ÕÒ³öÆäÖеĴíÎ󲢸ÄÕýÆäÖеĴíÎó¡£ import java.awt.*; import java.awt.event.*; import javax.swing.*; public class ButtonTest extends JFrame { private JButton plainButton, fancyButton; public ButtonTest() { super( \ Container container = getContentPane(); container.setLayout( new FlowLayout() ); µÚ 20 Ò³ ¹² 48 Ò³
Ïà¹ØÍÆ¼ö£º