Skip to main content

IS5103 Week 7 (Quiz)

 Quiz


1. An instance of ________ describes system errors. If this type of error occurs, there is little you can do beyond notifying the user and trying to terminate the program gracefully.


A). Error


2. The following code causes Java to throw ________.

int number = Integer.MAX_VALUE + 1;

A).no exceptions


3. What exception type does the following program throw?

public class Test {
public static void main(String[] args) {
String s = "abc";
System.out.println(s.charAt(3));
}
}


A). StringIndexOutOfBoundsException



4. Analyze the following code:

public class Test {
public static void main(String[] args) {
try {
String s = "5.6";
Integer.parseInt(s); // Cause a NumberFormatException

int i = 0;
int y = 2 / i;
}
catch (Exception ex) {
System.out.println("NumberFormatException");
}
catch (RuntimeException ex) {
System.out.println("RuntimeException");
}
}
}

A). The program has a compile error.


5. What is displayed on the console when running the following program?

public class Test {
public static void main(String[] args) {
try {
p();
System.out.println("After the method call");
}
catch (NumberFormatException ex) {
System.out.println("NumberFormatException");
}
catch (RuntimeException ex) {
System.out.println("RuntimeException");
}
}

static void p() {
String s = "5.6";
Integer.parseInt(s); // Cause a NumberFormatException

int i = 0;
int y = 2 / i;
System.out.println("Welcome to Java");
}
}


A). The program displays NumberFormatException.


6. Which class do you use to read data from a text file?


A). Scanner


7. Which of the following statements are correct?


I:

try (PrintWriter output = new PrintWriter("output.txt")) {
output.println("Welcome to Java");
}

II:
try (PrintWriter output = new PrintWriter("output.txt");) {
output.println("Welcome to Java");
}

III:
PrintWriter output;
try (output = new PrintWriter("output.txt");) {
output.println("Welcome to Java");
}

IV:
try (PrintWriter output = new PrintWriter("output.txt");) {
output.println("Welcome to Java");
}
finally {
output.close();
}


A). 1. I

      2. II

      3. III


8. Which of the following statements are correct?

I:

try (PrintWriter output = new PrintWriter("output.txt")) {
output.println("Welcome to Java");
}

II:
try (PrintWriter output = new PrintWriter("output.txt");) {
output.println("Welcome to Java");
}

III:
PrintWriter output;
try (output = new PrintWriter("output.txt");) {
output.println("Welcome to Java");
}

IV:
try (PrintWriter output = new PrintWriter("output.txt");) {
output.println("Welcome to Java");
}
finally {
output.close();
}


A). 1. I

      2. II

      3. III


9. The difference between a checked and an unchecked exception is


A). an unchecked exception requires no throws clause


10. If an exception is thrown and is not caught anywhere in the program, then the program terminates.


A). True















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