Java Chapter 4

¡Supera tus tareas y exámenes ahora con Quizwiz!

D

"AbA".compareToIgnoreCase("abC") returns ___________. A. 1 B. 2 C. -1 D. -2 E. 0

B

"abc".compareTo("aba") returns ___________. A. 1 B. 2 C. -1 D. -2 E. 0

B

'3' - '2' + 'm' / 'n' is ______. A. 0 B. 1 C. 2 D. 3

B

A Java character is stored in __________. A. one byte B. two bytes C. three bytes D. four bytes

ABCD

A. if (s.startsWith("Java")) ... B. if (s.indexOf("Java") == 0) ... C. if (s.substring(0, 4).equals("Java")) ... D. if (s.charAt(0) == 'J' && s.charAt(1) == 'a' && s.charAt(2) == 'v' && s.charAt(3) == 'a') ...

AB

An int variable can hold __________. A. 'x' B. 120 C. 120.0 D. "x" E. "120"

B

Math.asin(0.5) returns _______. A. 30 B. Math.toRadians(30) C. Math.PI / 4 D. Math.PI / 2

A

Math.sin(Math.PI) returns _______. A. 0.0 B. 1.0 C. 0.5 D. 0.4

C

Note that the Unicode for character A is 65. The expression "A" + 1 evaluates to ________. A. 66 B. B C. A1 D. Illegal expression

A

Note that the Unicode for character A is 65. The expression 'A' + 1 evaluates to ________. A. 66 B. B C. A1 D. Illegal expression

AD

Suppose Character x = new Character('a'), __________________ returns true. A. x.equals(new Character('a')) B. x.compareToIgnoreCase('A') C. x.equalsIgnoreCase('A') D. x.equals('a') E. x.equals("a")

C

Suppose x is a char variable with a value 'b'. What is the output of the statement System.out.println(++x)? A. a B. b C. c D. d

D

The __________ method parses a string s to a double value. A. double.parseDouble(s); B. Double.parsedouble(s); C. double.parse(s); D. Double.parseDouble(s);

D

The statement System.out.printf("%10s", 123456) outputs ___________. (Note: * represents a space) A. 123456**** B. 23456***** C. 12345***** D. ****123456

D

The statement System.out.printf("%3.1e", 1234.56) outputs ___________. A. 0.1e+04 B. 0.123456e+04 C. 0.123e+04 D. 1.2e+03 E. 1.23+03

E

The statement System.out.printf("%3.1f", 1234.56) outputs ___________. A. 123.4 B. 123.5 C. 1234.5 D. 1234.56 E. 1234.6

C

The statement System.out.printf("%5d", 123456) outputs ___________. A. 12345 B. 23456 C. 123456 D. 12345.6

ACE

To check if a string s contains the suffix "Java", you may write A. if (s.endsWith("Java")) ... B. if (s.lastIndexOf("Java") >= 0) ... C. if (s.substring(s.length() - 4).equals("Java")) ... D. if (s.substring(s.length() - 5).equals("Java")) ... E. if (s.charAt(s.length() - 4) == 'J' && s.charAt(s.length() - 3) == 'a' && s.charAt(s.length() - 2) == 'v' && s.charAt(s.length() - 1) == 'a') ...

A

To obtain the arc sine of 0.5, use _______. A. Math.asin(0.5) B. Math.asin(Math.toDegrees(0.5)) C. Math.sin(Math.toRadians(0.5)) D. Math.sin(0.5)

B

To obtain the sine of 35 degrees, use _______. A. Math.sin(35) B. Math.sin(Math.toRadians(35)) C. Math.sin(Math.toDegrees(35)) D. Math.sin(Math.toRadian(35)) E. Math.sin(Math.toDegree(35))

D

What is Math.rint(3.5)? A. 3.0 B. 3 C. 4 D. 4.0 E. 5.0

C

What is Math.round(3.6)? A. 3.0 B. 3 C. 4 D. 4.0

A

What is the output of System.out.println('z' - 'a')? A. 25 B. 26 C. a D. z

B

What is the return value of "SELECT".substring(0, 5)? A. "SELECT" B. "SELEC" C. "SELE" D. "ELECT"

A

What is the return value of "SELECT".substring(4, 4)? A. an empty string B. C C. T D. E

ABCE

Which of the following are valid specifiers for the printf statement? A. %4c B. %10b C. %6d D. %8.2d E. %10.2e

AB

Which of the following assignment statements is correct? A. char c = 'd'; B. char c = 100; C. char c = "d"; D. char c = "100";

D

Which of the following is the correct expression of character 4? A. 4 B. "4" C. '\0004' D. '4'

C

Which of the following is the correct statement to return JAVA? A. toUpperCase("Java") B. "Java".toUpperCase("Java") C. "Java".toUpperCase() D. String.toUpperCase("Java")

CDE

____________________ returns true. A. "peter".compareToIgnoreCase("Peter") B. "peter".compareToIgnoreCase("peter") C. "peter".equalsIgnoreCase("Peter") D. "peter".equalsIgnoreCase("peter") E. "peter".equals("peter")


Conjuntos de estudio relacionados

Anticoagulants, Antiplatelets, & Fibrolytics

View Set

Chapter 31: The Child with Endocrine Dysfunction

View Set

EMT Chapter 38 Vehicle Extrication and Special Rescue

View Set

Module 36, Exemplar C, Prioritizing Care: NCLEX Practice

View Set

Unit 5:Agriculture:Primary Economic Activities

View Set

Chem 237 Experiment 5: Simple Distillation & Gas Chromatography

View Set

Essentials of Physical Anthropology: Chapter 8, ANTH 1101: Final Exam, Anthropology 101 Exam 1, Anthropology 101 Exam 2, Anthropology 101 Final, Anthropology 101- Exam 3, Anthropology 101, Anthropology 101, Anthropology 101, Anthropology 101, ANTHROP...

View Set