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

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

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