题目内容

To declare an int variable x with initial value 200, you write

A. int x = 200.0;
B. int x = 200l;
C. int x = 200L;
D. int x = 200;

查看答案
更多问题

Which of the following is incorrect?

A. double x = 1.0;
B. float x = 1.0;
C. long x = 9;
D. int x = 9;

Which of the following assignment statements is illegal?

A. int t = 23;
B. short s = 10;
C. float f = -34;
D. float f = 34.0;

Analyzethefollowingcode.publicclassTest{publicstaticvoidmain(String[]args){intmonth=09;System.out.println("monthis"+month);}}

A. Theprogramdisplaysmonthis9.
B. Theprogramdisplaysmonthis09.
C. Theprogramhasasyntaxerror,because09isanincorrectliteralvalue.
D. Theprogramdisplaysmonthis9.0.

Analyzethefollowingcode:publicclassTest{publicstaticvoidmain(String[]args){intn=10000*10000*10000;System.out.println("nis"+n);}}

A. Theresultof10000*10000*10000istoolargetobestoredinanintvariablen.Thiscausesanoverflowandtheprogramisaborted.
B. Theresultof10000*10000*10000istoolargetobestoredinanintvariablen.ThiscausesanoverflowandtheprogramcontinuestoexecutebecauseJavadoesnotreporterrorsonoverflow.
C. Theprogramdisplaysnis1000000000000.
D. Theresultof10000*10000*10000istoolargetobestoredinanintvariablen.ThiscausesanunderflowandtheprogramcontinuestoexecutebecauseJavadoesnotreporterrorsonunderflow.

答案查题题库