answersLogoWhite

0


Best Answer

import java.util.Scanner;

class NoMatchException extends Exception {

static void method() throws Exception{

String s = "India";

String s2 = " ";

try {

if (!s.equals(s2)){

throw new NoMatchException();

//System.out.println("Strings are equal");

}

else {

System.out.println("Strings are equal");

//throw new NoMatchException();

}

}

catch(NoMatchException ne){

System.out.println("Exception Found For String");

}

finally {

System.out.println("In Finally Block");

}

}

}

public class BasicException {

static void myMethod(int x, int y) throws Exception{

try {

if(x < y ) {

System.out.println("Y is greater then X");

throw new Exception();

}

else

System.out.println("Y is smaller");

}

catch(Exception ex) {

System.out.println("exception found");

//System.out.println(ex.toString());

}

finally {

System.out.println("FINALLY block");

}

}

public static void main(String args[]) throws Exception{

Scanner s = new Scanner(System.in);

int d, a, x, y;

System.out.println("Enter the value of x and y");

x = s.nextInt();

y = s.nextInt();

try {

BasicException.myMethod(x , y);

}catch(Exception e) {

System.out.println("main method exception");

System.out.println(e.toString());

}

try {

NoMatchException.method();

}

catch(NoMatchException e) {

System.out.println("Exception Caught");

}

try{

d=0;

a=42/d;

System.out.println("This will not be printed.");

}

catch(ArithmeticException e){

System.out.println("Division by zero.");

}

}

}

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Define an exception called NoMatchException that is thrown when a string is not equal to Symbiosis Write a Java program that uses this exception?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Define the term symbiosis?

Symbiosis describes a relationship where two entities depend on each other.


Is there a program that you can insert a list of terms and it will define them?

No.


define an effective program monitoring?

A camera


What is the hierarchy of the java program?

define the data types


Where dowe define interrupts in 8086?

Breaking the sequence of program


What is the national outreach program for fccla?

Define Financial Fitness.


Define program relocation?

program relocation is the process which modifies the object program so that it can be loaded at an address different from the location originally specified.


What is the difference between program and programming?

define program i. program means set of instruction which are required for a particular type of task is called program ii. set of instruction or commands which are given for the computer to do different activity or jobs or works is called program define programming the process of creating/modifying a program; some people's job, others' hobby


Define a catch block?

A Catch block is part of the exception handling mechanism in Java. It is used along with the try block. Ex: try { ... } catch (Exception e) { ... } The catch block is used to catch &amp; handle the exception that gets thrown in the try block.


Can you define video?

A video is a program, movie, or the like, that is available commercially on videocassette.


How do you pass in Anna university chennai?

Define c-program and give an example


Define how operating system is a control program?

operating system is a control program as it allow multiple task to performed on same window.