# Day08

Source: Internet
Author: User

Tags: notes

1.

Class Demo

{

void Show (int a,int b,float c) {}

}

A.void Show (int a,float c,int b) {}//yes

B,void Show (int a,int b,float c) {}//identical. Can not appear in the same class.

C.int Show (int a,float C,int b) {return A;} Yes

D.int Show (int a,float c) {return A;} Yes

--------------------------------------------------

2. Write the results.

Class Demo

{

public static void Main (string[] args)

{

int X=0,y=1;

if (++x==y--&x++==1| | --y==0)

System.out.println ("x=" +x+ ", y=" +y);

Else

System.out.println ("y=" +y+ ", x=" +x);

}

}

--------------------------------------------------

3.

Write out the results.

Class Demo

{

public static void Main (string[] args)

{

int a=3,b=8;

int c= (a>b)? a++:b++;

System.out.println ("a=" +a+ "\tb=" +b+ "\tc=" +c); 3 9 8

int d= (a>b)? ++a:++b;

System.out.println ("a=" +a+ "\tb=" +b+ "\td=" +d); 3 10 10

int e= (a<b)? a++:b++;

System.out.println ("a=" +a+ "\tb=" +b+ "\te=" +e); 4 10 3

int f= (a<b)? ++a:++b;

System.out.println ("a=" +a+ "\tb=" +b+ "\tf=" +f); 5 10 5

}

}

--------------------------------------------------

4. Write the results.

Class Demo

{

public static void Main (string[] args)

{

int m=0,n=3;

if (m>0)

if (n>2)

System.out.println ("A");

Else

System.out.println ("B");

}

}

--------------------------------------------------

5. Write the results.

public class Demo

{

public static void Main (String []args)

{

int i = 0, j = 5;

Tp:for (;;)

{

i++;

for (;;)

{

if (i > j--)

Break TP;

}

}

System.out.println ("i =" + i + ", j =" + J "); I=1,j=-1;

}

}

--------------------------------------------------

6. Write the results.

Class Demo

{

public static void Main (string[] args)

{

String foo= "Blue";

Boolean[] Bar=new boolean[2];

if (Bar[0]) An array of type//boolean default initialization value is False.

{

foo= "green";

}

System.out.println (foo);

}

}

--------------------------------------------------

7. Write the results.

public class Test

{

public static void Leftshift (int i, int j)

{

i+=j;

}

public static void Main (String args[])

{

int i = 4, j = 2;

Leftshift (i, j);

System.out.println (i); The 4 and Leftshift functions do not matter.

}

}

--------------------------------------------------

8. Write the results.

public class Demo

{

public static void Main (string[] args)

{

Int[] A=new int[1];

Modify (a);

System.out.println (A[0]); 1

}

public static void Modify (int[] a)

{

a[0]++;

}

}

--------------------------------------------------

9.

Class Test

{

public static void Main (string[] args)

{

String Foo=args[1];

String bar=args[2];

String Baz=args[3];

}

}

D:\>java Test Red Green Blue

What is the value of Baz?

A. Baz has value of ""

B. Baz has value of NULL

C. Baz has value of "Red"

D. Baz has value of "Blue"

E. Baz has value of "Green"

F. The code does not compile

G. The program throw-an exception

--------------------------------------------------

11.

Description: Function in the program and operation characteristics.

--------------------------------------------------

12.

Print 99 multiplication table

--------------------------------------------------

13. Print the following graphic

*

* *

* * *

* * * *

* * * * *

------------------------------------------------------

14.

Which of the following array definitions is wrong.

Add a single-line comment to the wrong answer and write the reason for the error.

A,float[]=new Float[3]; There is no array reference name.

B, the float f2[]=new float[];//array has no length.

C, float[] f1=new float[3];//yes.

D, boolean[] b={"true", "false", "true"};//error, data type mismatch. "True" This is a string type.

E, double f4[]={1,3,5}; Yes double d = 1; S.O.P (d);//1.0;

F, int f5[]=new int[3]{2,3,4}; Wrong, the right bracket cannot write a specific value, because the elements and the number of data in the curly braces are reflected.

G, float f4[]={1.2,3.0,5.4};//error. Because the element values in the array are double, plus f is the right one.

Day08

Related Article