Sunday, October 21, 2012

Java program to create user defined exception handling


import java.io.*;
class myException extends Exception
{ myException()
  { System.out.println("Error:Password too short");
  }
  myException(int n)
  { System.out.println("Error:Only adults can join");
  }
}
class user_exception
{ public static void main(String s[])throws IOException,myException
  { BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    try
    { System.out.print("Enter user name : ");
      String n=br.readLine();
      System.out.print("Enter your password : ");
      String m=br.readLine();
      if(m.length() <6)
        throw new myException();
      System.out.print("Enter your age : ");
      int o=Integer.parseInt(br.readLine());
      if(o<18)
        throw new myException(o);
    }
    catch(Exception e)
    {    }
  }
}   
Output

77 comments:

  1. Helpful to create user defined function in java ..java training in chennai

    ReplyDelete
  2. This is an awesome post.Really very informative and creative contents. These concept is a good way to enhance the knowledge.I like it and help me to development very well.Thank you for this brief explanation and very nice information.Well, got a good knowledge.
    Click here:
    angularjs training in rajajinagar
    Click here:
    angularjs training in marathahalli

    ReplyDelete
  3. Just stumbled across your blog and was instantly amazed with all the useful information that is on it. Great post, just what i was looking for and i am looking forward to reading your other posts soon!
    Click here:
    Microsoft azure training in sollinganallur
    Click here:
    Microsoft azure training in btm

    ReplyDelete
  4. I would like to thank you for your nicely written post, its informative and your writing style encouraged me to read it till end. Thanks

    java training in annanagar | java training in chennai

    java training in chennai | java training in electronic city

    ReplyDelete
  5. I am obliged to you for sharing this piece of information here and updating us with your resourceful guidance. Hope this might benefit many learners. Keep sharing this gainful articles and continue updating us.
    Software Testing Training in Chennai
    Software Testing Courses in Chennai
    Software Training Institutes in Chennai
    Software Testing Training Institutes in Chennai
    Software Testing Course

    ReplyDelete
  6. Its a good post and keep posting good article.its very interesting to read.
    Best Selenium Training Institute in Chennai | Selenium Course in Chennai

    ReplyDelete
  7. I was recommended this web site by means of my cousin. I am now not certain whether this post is written through him as nobody else recognise such precise about my difficulty. You're amazing! Thank you!
    angularjs online training

    apache spark online training

    informatica mdm online training

    devops online training

    aws online training

    ReplyDelete
  8. Thank you for such information. Please keep up the good work.
    Python training in kalyan nagar

    ReplyDelete
  9. Nice article about Java Program... I was in search of such article... At last found this easy one.
    Earn Money Now without any effort

    ReplyDelete
  10. Good articles, Have you heard of LFDS (Le_Meridian Funding Service, Email: lfdsloans@outlook.com --WhatsApp Contact:+1-9893943740--lfdsloans@lemeridianfds.com) is as USA/UK funding service they grant me loan of $95,000.00 to launch my business and I have been paying them annually for two years now and I still have 2 years left although I enjoy working with them because they are genuine Loan lender who can give you any kind of loan.

    ReplyDelete
  11. It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...data science courses

    ReplyDelete
  12. I truly appreciate essentially perusing the entirety of your weblogs. Basically needed to advise you that you have individuals like me who value your work. Certainly an extraordinary post. Caps off to you! The data that you have given is useful.
    data scientist training and placement

    ReplyDelete
  13. 매우 유용한 데이터를 제공합니다. 이 게시물은 나에게 매우 유용하다는 많은 조언을 제공합니다. 몇 가지 문제를 해결하는 데 큰 도움이됩니다. 유용한 기사를 공유해 주셔서 대단히 감사합니다.
    내 사이트를 방문하십시오.파워볼사이트
    많은 정보를 얻을 수 있습니다.

    ReplyDelete
  14. Title:
    Big Data Training in Chennai | Infycle Technologies

    Description:
    Are you looking for Big Data training in Chennai with placement opportunities? Then we, Infycle Technologies are with you to make your dream into reality. Infycle Technologies is one of the best Big Data Training Institute in Chennai, which offers various programs along with Big Data such as Oracle, Java, AWS, Hadoop, etc., in complete hands-on practical training with trainers, those are specialists in the field. In addition to the training, the mock interviews will be arranged for the candidates, so that they can face the interviews with the best knowledge. Of all that, 100% placement assurance will be given here. To have the words above in the real world, call 7502633633 to Infycle Technologies and grab a free demo to know more.
    Best aws traiining in Chennai

    ReplyDelete
  15. UNIQUE ACADEMY FOR COMMERCE, an institute where students enter to learn and leave as invincible professionals is highly known for the coaching for CA and CS aspirants.

    cs executive
    freecseetvideolectures/
    UNIQUE ACADEMY

    ReplyDelete
  16. Are you looking for Big Data training in Chennai with placement opportunities? Then we, Infycle Technologies are with you to make your dream into reality. Infycle Technologies is one of the best Big Data Training Institute in Chennai, which offers various programs along with Big Data such as Oracle, Java, AWS, Hadoop, etc., in complete hands-on practical training with trainers, those are specialists in the field. In addition to the training, the mock interviews will be arranged for the candidates, so that they can face the interviews with the best knowledge. Of all that, 100% placement assurance will be given here. To have the words above in the real world, call 7502633633 to Infycle Technologies and grab a free demo to know more.
    BEST SOFTWARE TRAINING IN CHENNAI

    ReplyDelete
  17. I want to say thanks to you. I have bookmark your site for future updates.
    data scientist certification malaysia

    ReplyDelete
  18. Your OctaFx Review Account Allows You To Login To Your Account In More Than 1 Country.

    ReplyDelete
  19. Thanks for sharing this information. I really like your blog post very much. You have really shared a informative and interesting blog post with people..
    data science course fee in hyderabad

    ReplyDelete
  20. Hi buddies, it is a great written piece entirely defined, continuing the good work constantly.
    data science classes in hyderabad

    ReplyDelete
  21. If you're looking for help in using it, just dial Quickbooks Customer Service +1 855-675-3194 to speak with a live representative.

    ReplyDelete
  22. When you or your company need help with QuickBooks or any other aspect of your business, dial Quickbooks Support Phone Number +1 888-210-4052.

    ReplyDelete
  23. Just dial Quickbooks Customer Service +1 888-210-4052 for quick assistance. The people behind the QuickBooks support phone number provide quick and accurate answers to any problem with your QuickBooks.

    ReplyDelete
  24. I read your blog its nice i like content its very useful for me
    QuickBooks error support helps to resolve yours problem regarding QuickBooks support .Our Company have l15 year experience to solve all QuickBooks error. Our team very hardworking.
    ND files in QuickBooks desktop

    ReplyDelete

  25. What a wonderful information it really helps me a lot to understand new things also have a look on this School with best rating.

    ReplyDelete
  26. Thank you for this important information it contains very good knowledge and helps me a lot Best CBSE School in Faridabad

    ReplyDelete
  27. HELLO, THANK YOU FOR VISITING MY BLOG.

    ENJOYED READING MY ARTICLE?

    kindly Support by sharing this and making donation to :

    BITCOIN : bc1qgkncx8pfu24cn8gzf4wpqv7fk5v0nvp4wm95pk

    ETHER: 0x14e41D03e09Af44EeF505bb265C616075B5b668b

    SHIBA INU: 0x14e41D03e09Af44EeF505bb265C616075B5b668b

    BTT: 0x14e41D03e09Af44EeF505bb265C616075B5b668b


    OTHER CURRENCY TO OUR MULTI COIN WALLET :0x14e41D03e09Af44EeF505bb265C616075B5b668b

    ReplyDelete
  28. Oh my goodness! Impressive article dude! Thanks, PLease Check my article also.

    Mod Apk and Games

    ReplyDelete
  29. Oh my goodness! Impressive article dude! Thanks, PLease Check my article also.

    Seekhlo Tech

    ReplyDelete
  30. Thanks a lot for giving us such helpful information.

    Best SaaS Development Company

    ReplyDelete
  31. Once again thanks for sharing your knowledge among the needful ones.
    it course center in chennai

    ReplyDelete
  32. This is such a great post, and was thinking much the same myself. Shillong Teer Previous Result

    ReplyDelete
  33. Active Detailing Franchise invites aspiring entrepreneurs to join our network and become part of a brand that values innovation, quality, and a commitment to exceeding customer expectations.

    ReplyDelete
  34. Safety barriers are installed in areas where hazards may occur, keeping the environment safe where vehicles, goods, and people move. It is an important protective measure for road safety and factory safety. So how do you choose a reliable safety barrier product? A lot depends on a reliable safety barrier manufacturer. In today’s guide, we’ll introduce you to 10 reliable Security barrier manufacturers in the United States. Read on to learn more.

    ReplyDelete
  35. Active Detailing excels in delivering top-tier Paint protection film services in Noida and Indirapuram.

    ReplyDelete
  36. This blog post on creating user-defined exceptions in Java provides an excellent breakdown of a crucial concept for Java developers. Understanding how to define and handle custom exceptions is essential for building robust applications, especially in complex projects where generic exceptions aren’t descriptive enough. For those interested in enhancing their technical skills in Java and digital marketing, our Digital Marketing Course In Delhi covers a range of foundational and advanced topics. This course can be beneficial for those aiming to expand their career into digital domains while keeping their programming skills relevant in today’s tech-driven marketing landscape.

    ReplyDelete
  37. The search for a dream home often revolves around three essential factors: location, comfort, and amenities. Exotica Dreamville , located in the heart of Sector 16C, Noida Extension, ticks all these boxes and more. With ready-to-move-in 2/3 BHK apartments, this project offers an ideal living space for families seeking a blend of luxury and functionality.

    ReplyDelete
  38. 💬 Comment on the Java Program:

    This Java program demonstrates custom exception handling by creating a user-defined exception class myException. It checks two user inputs:

    Password length: If the password length is less than 6 characters, it throws a custom exception with the message "Error: Password too short".
    Age validation: If the user's age is less than 18, it throws another custom exception with the message "Error: Only adults can join".
    The BufferedReader is used for input, and exceptions are handled gracefully in the try-catch block. However, the catch block could be improved by adding e.printStackTrace() for better debugging.

    🌟 On a related note: For learners interested in enhancing their programming skills further, especially in data-driven applications, there are data Science courses in Delhi that incorporate Java for big data processing and machine learning—great options to explore!

    ReplyDelete
  39. By the way, speaking of useful skills, if you’re exploring advanced topics like exception handling in Java, you might also find data Science courses in Delhi interesting. These courses often cover how Java can be used in big data applications and data processing pipelines, which could be a great next step for expanding your programming expertise.

    ReplyDelete
  40. This Java program demonstrates user-defined exceptions to handle password length and age validation. If the password is too short (less than 6 characters), it throws an exception, and if the user's age is below 18, another exception is triggered. However, the catch block is empty, which means exceptions are caught but not properly handled or displayed, making debugging difficult.

    🔹 Suggestion: Instead of printing messages inside the exception constructor, use super(message) in the myException class to pass meaningful error messages and display them using e.getMessage() in the catch block.

    On a different note, if you're interested in enhancing your skills in the healthcare industry, consider Medical Coding Courses in Delhi. These courses provide essential knowledge in medical documentation and coding, offering excellent career opportunities.

    Happy coding and continuous learning! 🚀

    ReplyDelete
  41. Oracle Java is the #1 programming language and development platform. It reduces costs, shortens development timeframes, drives innovation, and improves application services. Java continues to be the development platform of choice for enterprises and developers.
    Medical Coding Course in Hyderabad

    ReplyDelete
  42. Great explanation! Your step-by-step breakdown of creating a user-defined exception in Java is super helpful for beginners and intermediate learners alike.

    Medical Coding Courses in Delhi

    ReplyDelete
  43. Coimbatore is a popular state of Tamil Nadu. The people of Coimbatore have an entrepreneurial mindset. The people are mainly from the Tamil community with a significant number of Telegus. Nowadays technology is emerging rapidly. Medical coding is also becoming an emerging technology to make it standardized. Medical coding courses in Coimbatore provide career growth and several opportunities for students to grow more. In Coimbatore, many medical coding institutes are offering technology-based medical coding courses for students and professionals who want to build their careers in this field.

    https://iimskills.com/medical-coding-courses-in-coimbatore/

    ReplyDelete
  44. Thanks for sharing! This Java program demonstrates user-defined exceptions to validate password length and age efficiently.

    Medical Coding Courses in Chennai

    ReplyDelete
  45. Learn Java programming with examples and solutions for various topics such as area, volume, series, matrix, sort, conversion, and star patterns. Download PDF files of each program with source code and output.
    data Science courses in Delhi

    ReplyDelete
  46. Khelo24Bet is a top-notch online betting platform designed to cater to sports enthusiasts and game lovers. Offering a vast array of betting options, from popular sports like cricket, football, and tennis to exciting games, Khelo24Bet provides a seamless and secure betting experience. The platform stands out for its competitive odds, live betting features, and easy-to-navigate interface, making it ideal for both new and seasoned bettors. With a strong emphasis on security and fair play, Khelo24Bet ensures that your transactions and personal information are protected, allowing you to focus on enjoying your betting journey to the fullest.

    ReplyDelete
  47. ​This Java program demonstrates how to use user-defined exceptions to validate user input for password length and age. Medical Coding Courses in Delhi

    ReplyDelete
  48. UNI Assignment Help provides dependable academic support, ensuring timely, well-crafted, plagiarism-free assignments for university students at budget-friendly rates.

    ReplyDelete
  49. In the ever-evolving world of forex trading, Winprofx has rightfully earned its place as the Best Forex Trading Platform and one of the most trusted names among the Top Forex Brokers 2025, thanks to its seamless user experience, advanced trading tools, and unwavering commitment to trader success. Offering access to a vast range of trading instruments including major, minor, and exotic currency pairs, commodities, and indices, Winprofx is designed for both beginners and professional traders. With ultra-low spreads, lightning-fast execution, and robust risk management tools, it empowers traders to execute strategies with precision and confidence. The platform stands out with features like AI-powered market signals, advanced charting options, automated trading capabilities, and copy trading that lets users replicate the success of top-performing traders in real-time. Beyond just tools, Winprofx focuses heavily on education and community, offering webinars, market insights, and personalized support to help users grow and adapt to market trends. Its commitment to transparency, regulatory compliance, and 24/7 customer service ensures a secure and supportive environment for global traders. Whether you're trading from your desktop or mobile device, Winprofx offers a cutting-edge solution that truly sets the standard for the Top Forex Brokers 2025.



    Best Forex Trading Platform-





    ReplyDelete
  50. "The Digital Marketing course at IIM SKILLS is an absolute game-changer. The curriculum is well-structured, and the instructors are very knowledgeable."

    https://iimskills.com/data-science-courses-in-india/

    ReplyDelete
  51. I think this could be very helpful to JAVA programmers great job laying out the logic!
    Data Science Courses in India

    ReplyDelete
  52. Thanks for sharing! This Java program demonstrates user-defined exceptions for password length and age validation, but an empty catch block may hinder proper error handling.


    Data Science Courses in India

    ReplyDelete
  53. The course structure is very comprehensive and easy to follow. It includes all the major aspects of Data Science.

    ReplyDelete
  54. They taught data cleaning techniques exceptionally well.
    Data Science Courses in India

    ReplyDelete
  55. The code you've provided defines a custom exception myException that is thrown in two cases: when the password is too short or when the user is under 18 years old. Data Science Courses in India

    ReplyDelete