Skip to main content

IS5103 WEEK-4 QUIZE'S


WEEK-4


Q1. Suppose your method does not return any value, which of the following keywords can be used as a return type?

Select one:

A.

void

B.

int

C.

public

D.

double

E.

None of the above


Q2. Does the method call in the following method cause compile errors?


public static void main(String[] args) {
Math.pow(2, 4);
}

Select one:

A.

Yes

B.

No

Q3. You should fill in the blank in the following code with ________.


public class Test {
public static void main(String[] args) {
System.out.print("The grade is ");
printGrade(78.5);

System.out.print("The grade is ");
printGrade(59.5);
}

public static ________ printGrade(double score) {
if (score >= 90.0) {
System.out.println('A');
}
else if (score >= 80.0) {
System.out.println('B');
}
else if (score >= 70.0) {
System.out.println('C');
}
else if (score >= 60.0) {
System.out.println('D');
}
else {
System.out.println('F');
}
}
}

Select one:

A.

int

B.

double

C.

char

D.

void

E.

boolean

Q4. You should fill in the blank in the following code with ________.


public class Test {
public static void main(String[] args) {
System.out.print("The grade is " + getGrade(78.5));
System.out.print("\nThe grade is " + getGrade(59.5));
}

public static ________ getGrade(double score) {
if (score >= 90.0)
return 'A';
else if (score >= 80.0)
return 'B';
else if (score >= 70.0)
return 'C';
else if (score >= 60.0)
return 'D';
else
return 'F';
}
}

Select one:

A.

char

B.

void

C.

int

D.

double

E.

boolean

Q5. Given the following method


static void nPrint(String message, int n) {
while (n > 0) {
System.out.print(message);
n--;
}
}

What is the output of the call nPrint('a', 4)?

Select one:

A.

aaa

B.

aaaa

C.

aaaaa

D.

invalid call

Q6. Given the following method


static void nPrint(String message, int n) {
while (n > 0) {
System.out.print(message);
n--;
}
}

What is k after invoking nPrint("A message", k)?

int k = 2;
nPrint("A message", k);

Select one:

A.

0

B.

1

C.

2

D.

3

Q7. Analyze the following code.


public class Test {
public static void main(String[] args) {
System.out.println(max(1, 2));
}

public static double max(int num1, double num2) {
System.out.println("max(int, double) is invoked");

if (num1 > num2)
return num1;
else
return num2;
}

public static double max(double num1, int num2) {
System.out.println("max(double, int) is invoked");

if (num1 > num2)
return num1;
else
return num2;
}
}

Select one:

A.

The program runs and prints 2 followed by "max(double, int)" is invoked.

B.

The program runs and prints 2 followed by "max(int, double)" is invoked.

C.

The program cannot compile because you cannot have the print statement in a non-void method.

D.

The program runs and prints "max(int, double) is invoked" followed by 2.

E.

The program cannot compile because the compiler cannot determine which max method should be invoked.

Q8. (char)('a' + Math.random() * ('z' - 'a' + 1)) returns a random character ________.

Select one:

A.

between 'b' and 'z'

B.

between 'b' and 'y'

C.

between 'a' and 'y'

D.

between 'a' and 'z'

Q9. Which of the following is the best for generating random integer 0 or 1?

Select one:

A.

(int)Math.random() + 1

B.

(int)(Math.random() + 0.5)

C.

(int)(Math.random() + 0.8)

D.

(int)Math.random()

E.

(int)(Math.random() + 0.2)


Q10. The client can use a method without knowing how it is implemented. The details of the implementation are encapsulated in the method and hidden from the client who invokes the method. This is known as ________.

Select one or more:

A.

encapsulation

B.

simplifying method

C.

method hiding

D.

information hiding





















































































Comments

Popular posts from this blog

IS5203 Type 2 Post Assessment and Final Quiz

  Carlos has just created a new subnet for the finance department. He needs to be able to allow the employees in finance to retrieve files from the sales server, which is located in another subnet. Which of the following OSI model layers would it be necessary to categorize the device into? a. Layer 4 b. Layer 6 c. Layer 2 d. Layer 3 All of the cubicles in a company's office have cables that run up to the ceiling and across to an IDF. Inside the IDF, they connect directly to the latest generation switch available from the networking equipment vendor that they have chosen. Which of the following describes the physical topology most likely in use? a. mesh

GE5103-2 Project Management [Aug 23 Syllabus]

    Some of the advantages of using time boxes and cycles in project coordination efforts include creating urgency, measuring progress, and allowing for predictable measurements. A)        True 2.    Even though most project managers are not contract specialists, they need to understand the process well enough to coordinate with the team. For the current assignment, you are looking at a short-term and small effort with a contractor of just a few hours without significant clarity. Which of the following would be the most applicable contract to use in this situation? A)        Time and materials 3. The project you are working on has had modifications to the plan from the start and even how the project is run. Project governance covers all of the 3 following except: A)        Naming The project manager 4. Of the following, which is most likely a trigger condition defined early in the project? A) Alerting Governance board if 10 percent over schedule 5. Of the following options, which stand

GE5163 Week8 ( Final Exam ) Quize's

  A process or product that is insensitive to normal variation is referred to as being Select one: a. in specification b. capable c. robust d. out of control Feedback Your answer is correct. A completed failure mode and effects analysis (FMEA) results in the following assessment rating.      Occurrence = 4      Severity = 8      Detection = 10 What is the risk priority number (RPN) for this FMEA? Select one: a. 42 b. 22 c. 320 d. 120 Feedback Your answer is correct. In a visual inspection situation, one of the best ways to minimize deterioration of the quality level is to: Select one: a. have a program of frequent eye exams. b. retrain the inspector frequently. c. add variety to the task. d. have a standard to compare against as an element of the operation. Feedback Your answer is correct. Which of the following elements is least necessary to a good corrective action feedback report? Select one: a. What caused the failure b. Who caused the failure c. What correction has been made d. Wh