1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
taurus [48]
3 years ago
10

What is displayed on the console when running the following program? class Test { public static void main(String[] args) { try {

method(); System.out.println("After the method call"); } catch (RuntimeException ex) { System.out.println("RuntimeException"); } catch (Exception ex) { System.out.println("Exception"); } } static void method() throws Exception { try { String s = "5.6"; Integer.parseInt(s); // Cause a NumberFormatException int i = 0; int y = 2 / i; System.out.println("Welcome to Java"); } catch (RuntimeException ex) { System.out.println("RuntimeException"); } catch (Exception ex) { System.out.println("Exception"); } } } Question 8 options:

Computers and Technology
1 answer:
Nutka1998 [239]3 years ago
8 0

Answer:

RuntimeException

After the method call

Explanation:

Image showing the program output when executed is attached.

In the code snippet given, inside the main method which is the beginning of program execution, there is a try-catch blocks.

The try block is executed first and the catch block is only executed if an exception is thrown.

The try block has two statement to execute:

try {

        method();

        System.out.println("After the method call");

}

The first statement is executed by calling the method called method(). The second statement display the output: "After the method call".

When method() is called, a runtime exception is thrown and a catch block is executed which display the message: "RuntimeException".

runtime exception occur during the program execution. From the above code snippet, the runtime exception is thrown/caused by the line below:

Integer.parseInt(s);

It is cause because the when the string is converted to integer, it is not assigned to any variable and this lead to the runtime exception.

You might be interested in
Write a client program that writes a struct with a privateFIFO name (call it FIFO_XXXX, where XXXX is the pid that you got from
ivann1987 [24]

Answer:

client code:

#include <stdio.h>

#include <fcntl.h>

#include <sys/stat.h>

#include <sys/types.h>

#include <unistd.h>

#include <stdlib.h>

#include <string.h>

int main (void)

{

 struct values

 {

   char privateFIFO[14];

   int intbuff;

 }input;

 int fda;  // common FIFO to read to write to server

 int fdb;      // Private FIFO to read from server

 int clientID;

 int retbuff;

 char temp[14];

 clientID = getpid();

 strcpy(input.privateFIFO, "FIFO_");

 sprintf(temp, "%d", clientID);

 strcat(input.privateFIFO, temp);

 printf("\nFIFO name is %s", input.privateFIFO);

 // Open common FIFO to write to server

 if((fda=open("FIFO_to_server", O_WRONLY))<0)

    printf("cant open fifo to write");

 write(fda, &input, sizeof(input));    // write the struct to the server

 close(fda);

 // Open private FIFO to read

 if((fdb=open(input.privateFIFO, O_RDONLY))<0)

    read(fdb, &retbuff, sizeof(retbuff));

 printf("\nAll done\n");

 close(fdb);

}

server code:

#include <stdio.h>

#include <errno.h>

#include <fcntl.h>

#include <sys/stat.h>

#include <sys/types.h>

#include <unistd.h>

#include <stdlib.h>

#include <string.h>

struct values

 {

   char privateFIFO[14];

   int intbuff;

 }input;

int main (void)

{

 int fda;  //common FIFO to read from client

 int fdb;  //private FIFO to write to client

 int retbuff;

 int output;

// create the common FIFO  

 if ((mkfifo("FIFO_to_server",0666)<0 && errno != EEXIST))

       {

       perror("cant create FIFO_to_server");

       exit(-1);

}

// open the common FIFO

 if((fda=open("FIFO_to_server", O_RDONLY))<0)

    printf("cant open fifo to write");

output = read(fda, &input, sizeof(input));

// create the private FIFO

 if ((mkfifo(input.privateFIFO, 0666)<0 && errno != EEXIST))

 {

   perror("cant create privateFIFO_to_server");

   exit(-1);

 }

 printf("Private FIFO received from the client and sent back from server is: %d", output);

 //open private FIFO to write to client

if((fdb=open(input.privateFIFO, O_WRONLY))<0)

   printf("cant open fifo to read");

 write(fdb, &retbuff, sizeof(retbuff));

 close(fda);

 unlink("FIFO_to_server");

 close(fdb);

 unlink(input.privateFIFO);

}

Explanation:

3 0
3 years ago
Write a short-essay discussing your own stand on social media usage for students.​
hjlf

Answer:

More than half of the world’s population uses the internet. This is highlighted by social media users increasing by 21% since 2015, with 2.8 billion users reported globally in 2017.

Humans are social animals. We always like to remain in some group or another, and we prefer to follow what this group does. All of our traditions and cultures are the product of <em><u>this</u></em> group-oriented facet of human nature.Everyone is connected to one another in this vast network generated by the Internet.It illuminates the lives of thousands of people by spreading knowledge internationally, thereby making us global citizens. 

<h2><em><u>NOT</u></em><em><u> </u></em><em><u>COPIED</u></em><em><u> </u></em><em><u>ANSWER</u></em><em><u> </u></em></h2>
3 0
2 years ago
Which magazine introduced the first microcomputer kit for the mits altair in its january 1975 issue?
Tcecarenko [31]

Answer:

Popular Electronics  is the correct answer.

Explanation:

It is the first magazine that released in the year 1975, Jan. The following magazine is about the initial microcomputer kit which for the Mits Altair.

So, that's why the following answer is not false because it is the first magazine that released the article about the following microcomputer kit that is update on the cover of the magazine.

6 0
3 years ago
. In testing, what is the role of an oracle?
ikadub [295]

Answer:

The role of test oracle is to determine if a test has passed or failed. Oracle compares the outputs of the system under a  test, for a given test-case input, and the output(s) that should have. A test oracle works on specifying constraints on the output(s) for a set of inputs. An oracle could be:

  • a program which tells if the output is correct.
  • documentation that specifies the correct output for inputs.
  • a human that can tell whether it is correct an output.

5 0
3 years ago
Keeping in mind the role the order of precedence plays in equations, what would Excel display as the result of the following equ
Arlecino [84]
Keeping in mind the role the order of precedence plays in equations, what would Excel display as the result of the following equation?

=(24+75)/(6*3)
=99/18
= 5.5
18)99.0.
90.0
9.0

D. 5.5



6 0
3 years ago
Other questions:
  • The _____ is the area in Microsoft Excel where you can perform file commands such as Save, Open, and Print
    15·1 answer
  • "Suppose that instead of always selecting the first activity to finish, we instead select the last activity to start that is com
    14·1 answer
  • Press the _______ key to move to the next cell in a row.
    12·2 answers
  • A user complains that his new mouse doesn't work right. He has an old system at home and when he has had this problem, he cleane
    11·2 answers
  • Which of the following operating systems is able to join a domain a) Microsoft office pro b) Microsoft surface R.T. c) google an
    9·2 answers
  • The goal expressed in this definition states that data visualization is about ______ . 1. Interpreting 2. Perceiving 3. Facilita
    6·1 answer
  • Write an expression that computes the integer average of the int variables exam1 and exam2 (both declared and assigned values).
    15·1 answer
  • 1
    7·1 answer
  • What dd command would you use to copy the contents of a partition named /dev/drive1 to another partition, called /dev/backup?
    6·1 answer
  • Hazel has taught herself a variety of computer languages. She enjoys using her knowledge to write the programs for applications
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!