ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 26 May 2017 My Price 9.00

"switch (val)case 1System.out.print

"switch (val)

case 1

System.out.print(""P"")

case 2

case 3

System.out.print(""Q"")

break

case 4

System.out.print(""R"")

default

System.out.print(""S"")

What is the output?

A. PQS

B. PQ

C. S

D. P

 

Question 2

How many times will ""hello"" be printed by the following

for (int i = 0, i < 10, i++)

System.out.println(""hello"")

A. 9

B. 0

C. 11

D. 10

 

Question 3

When writing a subclass, which of all of the following are true?

A. You can override methods of the superclass

B. You can inherit methods from the superclass

C. You can define new methods in the subclass

D. All of the above

 

Question 4

Select the best answer.

Local variables are destroyed when

A. the constructor runs

B. you explicitly delete them

C. the object is no longer in use

D. the method ends

 

 

 

 

Question 5

Which of the following is a valid constructor method header for a class named Car?

A. Public Class Car

B. public car(String model)

C. public class Car(String model)

D. public Car(String model)

 

 

Question 6

For the code

int m = 0

while (m++ < 2)

System.out.print(m + "" "")

What is the output?

A. 0 1 2

B. 1 2

C. 1

D. 0 1

 

 

Question 7

Remember that the % operator evaluates to the remainder after integer division e.g. 8 % 4 is 0, 11 % 4 is 3. What is the value of x after the following?

int x = 0

for (int i = 1, i = 4)

System.out.println(""Test A"")

else if (val > 9)

System.out.println(""Test B"")

else

System.out. println(""Test C"")

Which one of the alternatives below will result in ""Test C"" being printed

A. val is 4

B. no values of val will do this

C. val < 4

D. val between 4 and 9

 

 

 

 

 

 

Question 11

Given

int quantity = 3

double value = 7.52

String number = ""one

Which of all of the following are valid assignments?

A. quantity = value

B. quantity = (int)value

C. value = quantity

D. quantity = (double)value

E. quantity = number

F. Both B and C

 

 

Question 12

Select the best answer.

A(n) ____ can add instance variables and methods to an existing class.

A. subclass

B. polymorphism

C. superclass

D. constructor

 

 

Question 13

What is the error in the following code fragment?

double data[] = new double[20]

data[20] = 15.25

A. Out-of-bounds error

B. Data not initialized

C. A two-dimensional array is required

D. A cast is required

 

 

Question 14

If you know that your loop must iterate at least one time, it is recommended that you use a _________ loop

A. do _ while

B. repeat

C. for

D. while

 

 

 

Question 15

Multiplying an int (such as 5) by a double (such as 0.1) gives

A. an exception is thrown

B. an int

C. an error

D. a double

 

 

Question 16

After executing this code segment

double v1 = 2000.0

double v2 = v1

v2 = v2 + 500.0

What will be the value of v1?

A. Unknown

B. 2000.0

C. 2500.0

D. 0.0

 

 

Question 17

Which of the following indicates that a method does not return a value?

A. double

B. static

C. void

D. public

 

 

Question 18

Where an inherited method is overridden, the type of the actual object, not the type of the reference to the object is used to determine which method to call?

True

False

 

 

Question 19

The compiler will generate an error if the same name but different signature is used for more than one method or constructor.

True

False

 

 

Question 20

Given this code fragment

int x = 5, y = 6, z = 7

foo(x, y, z)

System.out.println(x + "", "" + y + "", "" + z)

public void foo(int a, int b, int c)

a = a + 3

b = a + c

c = c + b

What is the output?

A. 5, 6, 7

B. 8, 12, 13

C. 2, 0, 4

D. 8, 15, 22

 

 


Question 21
javadoc comments begin and end with
A. // and //
B. /* and */
C. /** and */
D. /@ and @/


Question 22
When using the BlueJ debugger, a class must be compiled before you can set a break point in it?
True
False

 

Question 23

Which of the following are Java naming conventions?

#1: Classes start with an uppercase letter

#2: Methods start with an uppercase letter

#3: Object start with a lowercase letter

#4: Objects start with an uppercase letter

#5: Classes start with a lowercase letter

#6: Methods start with a lowercase letter

A. #1, #3 and #6

B. #4, #5 and #6

C. #1, #2 and #4

D. #3, #5 and #6

 

 

Question 24

Given the array

double cost[] = new double[5]

How would you access the last element of the array?

A. cost.get(4)

B. cost[4]

C. cost.get[5]

D. cost[5]

 

 

Question 25

In a program, you create an object of a class using the keyword ____.

A. abstract

B. extends

C. create

D. new

 

 

 

"switch (val)case 1System.out.print(""P"")case 2case 3System.out.print(""Q"")breakcase 4System.out.print(""R"")defaultSystem.out.print(""S"")What is the output?A. PQSB. PQC. SD. PQuesTon 2How many Tmes will ""hello"" be printed by the followingfor (int i = 0, i < 10, i++)System.out.println(""hello"")A. 9B. 0C. 11D. 10QuesTon 3When wriTng a subclass, which of all of the following are true?A. You can override methods of the superclassB. You can inherit methods from the superclassC. You can deFne new methods in the subclassD. All of the aboveQuesTon 4Select the best answer.Local variables are destroyed whenA. the constructor runsB. you explicitly delete themC. the object is no longer in useD. the method ends

Attachments:

Answers

(11)
Status NEW Posted 26 May 2017 12:05 AM My Price 9.00

-----------

Attachments

file 1495758167-Solutions file 2.docx preview (51 words )
H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly -----------onl-----------ine----------- an-----------d g-----------ive----------- yo-----------u e-----------xac-----------t f-----------ile----------- an-----------d t-----------he -----------sam-----------e f-----------ile----------- is----------- al-----------so -----------sen-----------t t-----------o y-----------our----------- em-----------ail----------- th-----------at -----------is -----------reg-----------ist-----------ere-----------d o-----------n -----------THI-----------S W-----------EBS-----------ITE-----------. ----------- Th-----------ank----------- yo-----------u -----------
Not Rated(0)