What is the output of the following program

Assignment Help JAVA Programming
Reference no: EM13810410

1. What RuntimeException, if any, will the following program throw?
class Exception1
{
public static void main(String[] args)
{
int x = 1/0;
}
}

2. How can you tell whether an exception is checked or unchecked? What is required of checked exceptions that is not required of those that are unchecked?

3. What is the output of the following program?
class Exception2
{
public static void main(String[] args)
{
try
{
aMethod();
System.out.println("After the call");
}
catch (ArithmeticException exception)
{
System.out.println("Arithmetic Exception");
}
catch (RuntimeException exception)
{
System.out.println("Runtime Exception");
}
System.out.println("After the try-catch statement");
}
private static void aMethod() throws RuntimeException
{
int x = 1/0;
}
}

What will happen if the order of the catch blocks is reversed?

4. Why won't the following program compile?
class Exception3
{
public static void main(String[] args)
{
if (Integer.parseInt(args[0]) == 0)
throw new Exception("Invalid Command Line Argument");
}
}
Correct it so it will compile.

5. Explain the difference between the keywords throw and throws. When is each used?

Reference no: EM13810410

Questions Cloud

Interactions in a presentation for senior leaders : Research and address the elements of organizational effectiveness that will improve interactions in a presentation for senior leaders:
Why would patricks actions be considered fraudulent : Patrick works for McGill’s Computer Repair, owned and operated by Frank McGill. As a computer technician, Patrick has grown accustomed to friends and family members asking for assistance with their personal computers. Why would Patrick’s actions be c..
Assignment on hospitality management : Hospitality Management
Compassionate hospitals and clinics : After Elizabeth received her bachelor's degree, she received no job offers. So she began working toward a master's degree in Human Resources Management.
What is the output of the following program : How can you tell whether an exception is checked or unchecked? What is required of checked exceptions that is not required of those that are unchecked? What is the output of the following program
How does the floation costs affect NPV decisions : Z. Company plans to raise $100 million. The flotation cost is expected ti be 8% issuing debt, 6% for issuing preferred stock and 5% for issuing common stock. How much additional capital will they need ti raise in order ti procure a net amount of $100..
What is the purpose and importance of financial analysis : A company’s financial statements consist of the balance sheet, income statement, and statement of cash flows. Describe what each statement tells us and their limitations. What is the purpose and importance of financial analysis?
About advance directives : Advance Directives
Dividend growth models to estimate the cost of equity : S. Company has the following capital structure: 45% debt, 15% preferred stock and 40% common stock. Assume the risk-free rate is 8%, the beta stock is 1.3 and the market risk premium (Rm - Rf) is 12%, Determine the weighted average costs of capital (..

Reviews

Write a Review

JAVA Programming Questions & Answers

  Replace the submit button

Replace the submit button (type="submit")with a regular button (type="button").  Once the buttonis clicked, display the user inputs in an HTML table below the form, if validations are successful

  Write a method named rowofstars

Write a method named rowOfStars that takes a single integer parameter n and returns a String with that many stars in it.

  Implement an intrusion detection system in java

You are to implement an intrusion detection system in java. Calculate a threshold for detecting an intrusion. The threshold is 2*(Sums of weights).

  Create a separate class for the selected product

Create a separate class for the selected product that holds the item number, the name of the product, the department in which the product belongs, the number of units in stock, and the price of each unit. You must use the product and class name th..

  Design and implementation of a hangman game

Design and Implementation of a Hangman game

  Structure named dog with a string field

Create a Structure named dog with a string field for the Dog's name. Create a Structure named Cat with a string field for the Cat's name. Write a program that declares one Dog and one Cat, and assign names to them. Write two overloaded functions n..

  Videorental store operatorrecord clients

Project is to design a program to help a videorental store operatorrecord clients' transactions - Design a primitive database indicating

  Objectivesbullto exercise the analysis design and

objectivesbullto exercise the analysis design and implementation activities of software development.bullto learn

  Menu based program to maintain student records

Write a menu based program to maintain student records. Your program should take the following inputs: 1. Student first name (max. 20 characters) 2. Student last name, (max. 20 characters) 3. Student scores (float/double), eg. 85.4 Problem

  Write the code with comment and output resultinterface and

write the code with comment and output resultinterface and polymorphismimplement a class quiz that implements the

  Write a java program that draws a square abcd

Write a java program that draws a square ABCD. The points A and B are arbitrarily specified by the user by clicking the mouse button. The orientation of the points should be counter-clockwise.

  Create a jframe that includes a jlabel that reads hello word

Design, implement, test, and debuga GUI-based version of a "Hello, World!" program. Create a JFrame that includes a JLabel that reads "Hello, World!" Use a layout manager of your choice

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd