image

Cracking Core Java Interviews 3rd Edition

A Comprehensive Guide to Crack Core Java Interviews in Investment Banks, HealthCare IT & Startups. It covers Core Java, Algorithms, Data Structures, Concurrency, Hibernate and Spring MVC.

Specifically for investment banking domain, healthcare IT and product companies i.e. UBS, RBS, Blackrock, Morgan Stanley, JP Morgan, Nomura, Barclays, Citibank, Markit, Bank of America, Goldman Sachs and other companies i.e. Global Logic, Adobe, hCentive, Edifecs, Expedia, Infosys, TCS, Sapient, Wipro, HCL etc.
Free Chapters PDF
1006 downloads
Buy Full PDF ₹250
3rd Edition
Last Updated : Friday, December 4, 2015 3:53:52 PM IST Total Page Hits 372

If a method throws NullPointerException in the superclass, can we override it with a method which throws RuntimeException?

The Answer is Yes.

In Order to understand this Question, you must know the rules for method overriding in Java

  1. You are free to throw any kind of Runtime Exception in the overriding class (not applicable for checked exception)
  2. You shall only throw same or narrowed checked exception (same or sub-class)
  3. The argument list must exactly match that of the overridden method. If they don’t then it will result in overloading rather than overriding.
  4. The return type must be a covariant type (same class or sub-class), i.e. you can narrow down the return type.



Similar Articles

1. Synechron Java Interview Questions

Collection of Java Interview Questions (Core Java, Spring, database and other concepts) for Synechron in banking and finance domain

2. Design Metro Smart Card System for Delhi using Java

Design a program in Java for Metro Smart Card System in Delhi. Evaluation criteria will be based on code completeness, code structure and quality, modularity, usage of OO principles, choice of data structure and unit tests.

3. What does volatile keyword do in a multi-threading environment

volatile keyword helps programmers write thread safe program