Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA 1. A program can be written in a messy and inefficient style and still compile without any errors and run flawlessly. True False 2

JAVA

1.

A program can be written in a messy and inefficient style and still compile without any errors and run flawlessly.

True

False

2

A binary search algorithm is written (as in the modules, for example) which searches a pre-sortedarray for some user-defined value, clientData. If clientData is stored in the array, it returns its array position, and if not found, it returns -1 (again, just like in the modules). Assume the array to be searched has 100 data elements in it. (Check all that apply):

[NOTE: due to common off-by-one interpretations when counting such things, if your predicted answer is within one (+1 or -1) of a posted option below, you can assume your prediction and the choice you are looking at are equivalent and check that option.]

A It might return to the client with an answer after only one comparison of data.
B It will always return with an answer in 7 or fewer comparisons of data.
C It will always return with an answer in 3 or fewer comparisons of data.
D

It may require as many as 99 comparisons of data before it returns.

3.

A program may create many objects/instances of the same class.

True

False

4.

Consider the following code fragment (assumed to be in an otherwise correct program):

 double [] dubArray1 = new double[75]; double [] dubArray2 = new double[100]; // there are no intervening statements. immediately following we have: dubArray1 = dubArray2; dubArray1[99] = 101; 

Check the true statements (may be more than one):

A It has no compiler or runtime errors.
B It has a compiler error.
C It has an array bounds violation, possibly causing a fatal runtime error.
D Some allocated memory becomes inaccessible, but that's not a fatal error.
E

It will compile without error but probably crash (i.e., generate a run-time error).

5.

If we operate bitwise on the following two decimal integers, as indicated, what are the two resulting decimal answers?

9 bitwise-or 7 9 bitwise-and 7

a 12 1
b 15 1
c 12 2
d 16 1
e 15 2

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions