Java Practical No.23, 24 & 25.pdf

  • Uploaded by: Meer Kukreja
  • 0
  • 0
  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Java Practical No.23, 24 & 25.pdf as PDF for free.

More details

  • Words: 82
  • Pages: 2
23.1) WRITE A PROGRAM TO ACCEPT A PASSWORD FROM THE USER AND THROW “AUTHENTICATION FAILURE ” EXCEPTION IF THE PASSWORD IS INCORRECT. PROGRAM: import java.util.*; class myException extends Exception { myException(String s) { super(s); } } class pass { public static void main(String args[]) { Scanner s=new Scanner(System.in); String s1=new String ("Nesp"); String s2; System.out.println("Enter the password:"); s2=s.next();

if(s1.equals(s2)) { System.out.println("Login Successfully...!"); } else { try {

throw new myException("Authenification Failure"); } catch(myException me) { System.out.println("Handle Exception"+me); } } } } OUPUT:

Related Documents


More Documents from "Meer Kukreja"