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
eduard
3 years ago
10

Consider the following code snippet:public static void main(String[] args) throws FileNotFoundExceptionWhich of the following st

atements about this code is correct?
a) The main method is designed to catch and handle all types of exceptions.
b) The main method is designed to catch and handle the FileNotFoundException.
c) The main method should simply terminate if the FileNotFoundException occurs.
d) The main method will not terminate if any exception occurs.
Computers and Technology
1 answer:
iVinArrow [24]3 years ago
8 0

Answer:

The main method should simply terminate if the FileNotFoundException occurs.

Explanation:

Considering the full code snippet

snippet:public static void main(String[] args) throws FileNotFoundException

public static void main(String[])

represent the entry point method to a java main method

The addition of

throws FileNotFoundException

widens the scope of the main method to explicitly specifies that an exception named the FileNotFoundException may be thrown.

So, if any part of the code explicitly throws the FileNotFoundException the compiler makes use of this to throw an exception.

By throwing an exception, the main method is not catching any exceptions, instead it handles the FileNotFoundException by throwing it to the source which invoked the main method

This is required by the compiler to terminate the program if the FileNotFoundException occurs.

You might be interested in
There have not been any changes to instruments or music in the last 50 years. The technology in music is still the same.
aliya0001 [1]

Answer:

False i hope this is rigth

7 0
3 years ago
Write a program that simulates flipping a coin repeatedly and continues until three consecutive heads. are tossed. At that point
quester [9]

Answer and Explanation:

#include <iostream>

#include <string>

#include <time.h>

#include <vector>

using namespace std;

//Takes user info

int user_info(string *name,char *gender){

   char G;

   cout<<"What is your name?: ";

   getline(cin, *name);

   cout<<"What is your gender(m/f):";

   cin>>G;

   cout<<endl;

   *gender = tolower(G);

   return 0;

}

//Toss coin(part 2)

bool coin_toss(double seed){

   double r;

   r = (double)seed/(double)RAND_MAX;

   //cout<<r;

   if (r<0.5) return true;

   return false;

}

//check results

float toss_result(vector<char> v,int *h){

   int num_heads=0;

   int num_toss = v.size();

   *h = 0;

   for(int i=0;i<num_toss;i++){

       if(v[i]=='h'){num_heads++;(*h)++;}

   }

   return (float)num_heads/(float)num_toss;

}

void show_result(int total_num,int head_num,float ratio){

   cout<<"it took you "<<total_num<<" tosses to get 3 heads in a row"<<endl;

   cout<<"on average you flipped heads "<<(ratio*100)<<"% of the time"<<endl;

}

int main()

{

   string name;

   char gender;

   string K; //Mr or Mrs

 

   cout<<"Welcome to coin toss! Get 3 heads in row to win!"<<endl;

 

   //part 1

   user_info(&name,&gender);

 

   if(gender == 'f') K = "Mrs.";

   else K = "Mr.";

 

   cout<<"Try to get 3 heads in a row. Good luck "<<K<<name<<"!"<<endl;

   char dummy = getchar();

 

   //part 2

   int num_toss;

   vector<char> toss_results;//store toss results

   bool result;//result of toss

   srand(time(0));

   while(true){

       //cout<<rand()<<endl;

       result = coin_toss(rand());

       cout<<"Press <enter> to flip"<<endl;

       while (1)

       {

           if ('\n' == getchar())

           break;

       }

     

 

     

       if(result) {toss_results.push_back('h');cout<<"HEAD"<<endl;}

       else {toss_results.push_back('t');cout<<"TAIL"<<endl;}

     

       num_toss = toss_results.size();

     

       if(num_toss>=3){

           if ((toss_results[num_toss-1] == 'h')&&(toss_results[num_toss-2] == 'h')&&(toss_results[num_toss-3] == 'h')){

               break;

           }

       }

   }

 

   //part 3

   float ratio_head;

   int num_of_heads;

   ratio_head = toss_result(toss_results,&num_of_heads);

 

   //part 4

 

   show_result(toss_results.size(),num_of_heads,ratio_head);

 

   return 0;

}

8 0
3 years ago
What version of ubuntu is linux mint 17.3 based on?
aliina [53]
It would be version 14.04! I run Ubuntu Linux on my pc with dual boot with Kali Linux! I hope this helped!

3 0
3 years ago
Name two commercial tools that can make a forensic sector-by-sector duplicate of a drive to a larger drive.
Temka [501]

Answer:

e34d4e

Explanation:

5 0
3 years ago
a new client has indicated that they are exercising due to advice from their physician, but they are generally amotivated. what
Orlov [11]

The factor that is a best choice for the personal trainer in their initial meeting is option a: Inquire further about what their motives are for participating.

<h3>What are the motives in motivation?</h3>

Psychologists is known to have shared motives into three types which are:

  • Biological motives
  • Social motives
  • Personal motives.

Note that the goal that is to be meant is for the fulfillment of  the client want or their  need.

Therefore asking the right question will go a long way in satisfying them. So, The factor that is a best choice for the personal trainer in their initial meeting is option a: Inquire further about what their motives are for participating.

Learn more about personal trainer from

brainly.com/question/19462080
#SPJ1

A new client has indicated that they are exercising due to advice from their physician, but they are generally amotivated. What would be the best choice for the personal trainer in their initial meeting?

Inquire further about what their motives are for participating.

Create a plan for overcoming barriers.

Establish short- and long-term goals.

Start establishing an emotional support system.

5 0
2 years ago
Other questions:
  • Which of the following typically have the highest auto insurance premiums?
    14·1 answer
  • In a ring-based system, procedure p is executing and needs to invoke procedure q. Procedure q's access bracket is (5,6,9). In wh
    15·2 answers
  • Utility software is also known as _____​
    11·1 answer
  • _____ refers to displaying information for the user's view.
    14·2 answers
  • Why laptop computer is called micro computer?​
    8·1 answer
  • How will you ensure that all of the network's applications and tcp/ip services also support ipv6?
    10·1 answer
  • The physical elements needed for the production of digital media, such as computers, servers, and so on are called the {Blank}
    8·1 answer
  • Apart from the OOPs concepts learned in this lesson, identify additional concepts and write an essay on their functions. Explain
    9·1 answer
  • Answered
    10·1 answer
  • 70 point Brainlist to best answer
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!