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

  Projectyou will create a secure parts inventory catalog

projectyou will create a secure parts inventory catalog system using model 2 architecture. the application will require

  Write a program that creates a two-dimensional array

Write a program that creates a two-dimensional (2D) array initialized with test data (for instance, use Random method to prepare an array of integers).

  What makes a program easy to modify

Describe the order of magnitude of the code section using Big(O) notation and Explain the relationship between dynamic storage allocation and recursion.

  Prepare a polynomial-time algorithm

Write a polynomial-time algorithm that, given an initial configuration (P_1, P_2, ..., P_k), decides if it is a winning configuration - Prepare a polynomial-time algorithm that decides if it is a winning configuration.

  T an array using insertion sort and track the number of swap

How to sort an array using insertion sort and track teh number of swaps during the sorting

  Produce a design document

You will design and deliver a website foes fictional client part-1 Website Design Document and produce a design document

  Draw a picture with an appearance

You must use the given Rectangle and Oval classes to draw a picture with an appearance as close as possible.

  What are the three types of errors

What are the three types of errors that you can encounter in a Java program? Describe them, and explain how you would minimize the errors

  You have to create a world class that contains a 2d array

you have to create a world class that contains a 2d array then create an abstract class called organism that contains

  A remote web-based file storage application

Develop a web-based application. The server-side part of the application must be developed using Java Servlets (possibly including JSP). The development of the client (browser) side will typically be a combination of HTML and Javascript.

  Design and implement a set of classes and interfaces and

design and implement a set of classes and interfaces and use them to evaluate the rtas resource requirements.nbspyour

  What is the smallest exponent

In storing number in a string of 16 bits, the first bit is used for the sign of the number, and the next 5 bits store the exponent plus the bias, and the remaining 10 bits store the mantissa. The bias is 15.

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