Java Exam 1 (2005)

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

Java is interpreted, but not compiled

False

If x is the String "Hi There", then x.toUpperCase().toLowerCase(); will return the original version of x. a) True b) False

Fasle

The expression "Java " + 1 + 2 + 3 evaluates to ________.

Java123

Java was developed by

Sun Microsystems

Which of the following statements is correct to display Welcome to Java on the console? a) System.out.println ('Welcome to Java'); b) System.out.println ("Welcome to Java"); c) system.println ("Welcome to Java"); d) System.out.print ('Welcome to Java'); e) system.out.print ("Welcome to Java");

System.out.println ("Welcome to Java");

Suppose you define a Java class as follows: public class Test { } In order to compile this program, the source code should be stored in a file named

Test.java

Select the TRUE statement from the choices below, regarding the difference between LAN and WAN network? a) WAN connects two or more LANs. b) LAN spans long distances. c) WAN spans short distances. d) LAN connects two or more WANs. e) none of the above

WAN connects two or more LANs.

If a program compiles fine, but it produces incorrect result, then the program suffers __________.

a logical error

Which of the following is an INVALID identifier? a) funny$ b) book-mark c) num_2 d) num2 e) _num

book-mark

Which of the following represents the correct increasing range of values for integer types, from left to right? a) byte long short int b) int byte short long c) byte short int long d) short byte long int e) none of the above

byte short int long

The reserved word __________ is required to declare a class.

class

Typing a { when you should have typed a ( is a/an _____________________ error.

compile-time

Which of the following is a correct was to declare variables? a) int length: int width; b) int length, width; c) int length; width; d) int length, int width; e) none of the above

int length, width;

The following code segment int num = 10.0; a) declares a variable num as integer and assigns it a value 10.0 b) only declares a variable num as integer c) only assigns it a value 10.0 d) is a compiler error e) is an example of how we use a narrowing assignment

is a compiler error

If a method does not have a return statement, then

it must be a void return type

Multiplying two numbers when you meant to add them is a/an __________________ error.

logical

Which of the following is not a reserved word? a) int b) void c) main d) float e) class

main

The relationship between a class and an object is best described as

objects are instances of classes

Parameters to methods always appear within __________.

parentheses

Well encapsulated classes have _______________ variables and ________________ methods.

private, public

Suppose you wish to provide an accessor method for a boolean variable called finished. What method header should be used?

public boolean getFinished()

The words required at the start of every "main" method definition are:

public static void

Assume String s = "ABCABC", the method __________ returns a new string "aBCaBC"

s.replace ('A', 'a');

The words ________________________ are reserved in Java as Boolean literals:

true, false

Given the declaration Account x = new Account (), which of the following statement is most accurate. a) x contains an int value. b) x contains an object of the Account type. c) x contains a reference to a Account object. d) You can assign an int value to x. e) none of the above

x contains a reference to a Account object.

Which of the following lines is not a Java comment? a) /*** comments ***/ b) // comments c) -- comments d) /***comments ***/ e) //**** comments ***\\

-- comments

What is the output of the following code segment? n1 = 3 - 14 / 2 % 5 + -3; System.out.println (n1);

-2

What is the value of variable i printed by the following code? public class Test { public static void main(String[] args) { int j = 0; int i = j++ * 5; System.out.println("What is i? " + i); } }

0

What is the output of the following code segment? d1 = 3 x 5 - 1.5 x 5 / 3; System.out.println (d1);

12.5

How many unique items can be represented by 10 bits?

2^10

int n1, n2; double d1, d2; What is the output of the following code segment? n1 = 17; d1 = n1/4; d2 = n1/2.0; System.out.println (d1 + " " + d2);

4.0 8.5

What is the value of variable i printed by the following code? public class Test { public static void main(String[] args) { int j = 0; int i = ++j *5; System.out.println("What is i? " + i); } }

5

One byte has how many bits?

8

________ is invoked to create an object.

A constructor

Analyze the following code: public class Test { public static void main(String[] args) { double radius; final double PI= 3.15169; double area = radius x radius x PI; System.out.println("Area is " + area); } }

The program has a compilation error because the variable radius is not initialized.


Conjuntos de estudio relacionados

Devices Operating at Different Layers of the OSI Model

View Set

Chapter 54. Underscoring Meaning: Williams and Music for Film

View Set

Spinal Cord Injury Review (Prep U)

View Set

NUTRI 300: 1.33 Exam #1 - Ch.1, Ch.2, Ch.11

View Set

Lesson 6: Medical Terminology (physio - salpingo)

View Set