JAVA 2016 Old Papers Solutions

3rd Semester

Year 2016 11 12 Create two classes ThreadA and ThreadB which implement Runnable interface. ThreadA displays all even numbers from 50 to 100 and ThreadB displays all odd numbers from 100 to 200. Define a main class which creates the objects of both the classes and displays the numbers as per the above mentioned specifications .

13. Create an interface called Calculate which has methods int add(int x, int y) and diff(int x, int y) to perform addition and subtraction of numbers passed as arguments.Then define a class that implements interface calculate .

14. Define String array of size 4 and store name of 4 students. Then display the names of students whose name has character ‘t

15. Write a program that displays content of folder database stored in d: drive. 

Group C

16: Explain dynamic polymorphism with example.
Runtime polymorphismor Dynamic Method Dispatchis a process in which a call to an overridden method is resolved at runtime rather than compile-time.In this process, an overridden method is called through the reference variable of a super class.The determination of the method to be called is based on the object being referred to by the reference variable.

17. What is exception? Write a program to catch the ArrayIndexOutOfBoundsException.

An exception is an abnormal condition that arises in a code sequence at run time. In other words, an exception is a run time error.When an Exception occurs the normal flow of the program is disrupted and the program/Application terminates abnormally, which is not recommended, therefore these exceptions are to be handled.Some reasons that may cause exception to occur

  • A user has entered invalid data.
  • A file that needs to be opened cannot be found.
  • A network connection has been lost in the middle of communications or the JVM has run out of memory.


Leave a Reply

Your email address will not be published.