Академический Документы
Профессиональный Документы
Культура Документы
3.Is this a complete and legal comment? Select the one correct answer.
/* // */
a.No, the block comment (/* ... */) is not ended since the single-line comment (
// ...) comments out the closing part.
b.It is a completely valid comment. The // part is ignored by the compiler.
c.This combination of comments is illegal and the compiler will reject it.
4.Which of the following do not denote a primitive data value in Java? Select th
e two correct answers.
a."t"
b.'k'
c.50.5F
d."hello"
e.false
5.Which of the following primitive data types are not integer types? Select the
three correct answers.
a.Type boolean
b.Type byte
c.Type float
d.Type short
e.Type double
6.Which integral type in Java has the exact range from -2147483648 (-231) to 214
7483647 (231-1), inclusive? Select the one correct answer.
a.Type byte
b.Type
c.Type
d.Type
e.Type
short
int
long
char
7.Which of the following lines are valid declarations?Select the three correct a
nswers.
a.char a = '\u0061';
b.char 'a' = 'a';
c.char \u0061 = 'a';
d.ch\u0061r a = 'a';
e.ch'a'r a = 'a';
8.Given the following code within a method, which statement is true? Select the
one correct answer.
int a, b;
b = 5;
a.Local
b.Local
c.Local
d.Local
e.Local
variable
variable
variable
variable
variable
a
b
a
b
b
is
is
is
is
is
not declared.
not declared.
declared but not initialized.
declared but not initialized.
initialized but not declared.
9.In which of these variable declarations will the variable remain uninitialized
unless explicitly initialized?
Select the one correct answer.
a.Declaration
b.Declaration
c.Declaration
d.Declaration
e.Declaration
of
of
of
of
of
12.The following program has several errors. Modify it so that it will compile a
nd run without errors.
import java.util.*;
package com.acme;
public class Exercise1 {
int counter;
void main(String[] args) {
Exercise1 instance = new Exercise1();
instance.go();
}
public void go() {
int sum;
int i = 0;
while (i<100) {
if (i == 0) sum = 100;
sum = sum + i;
i++;
}
System.out.println(sum);
}
}
13.The following program has several errors. Modify it so that it will compile a
nd run without errors.
// Filename: Temperature.java
PUBLIC CLASS temperature {
PUBLIC void main(string args) {
double fahrenheit = 62.5;
*/ Convert /*
double celsius = f2c(fahrenheit);
System.out.println(fahrenheit + 'F = ' + celsius + 'C');
}
14.Write sample program for print default primitive data type values?