JAVA Model Questions || BIM STUDY NOTES

3rd Semester

Model Questions

  1. Write a Java program to display all the numbers between -300 to -1 which when divided by 17 gives 7 as remainder and also displays sum of those numbers.

3.Make two threads, one displays odd number after one second and another thread display even



number after half second between -200 and -10.

4. Write a program that displays all the read-only files of a given folder.

5.Make a class named student with private member variables name, age, and public functions to
set, display and return values of member variables. Then create ten objects of the student class,
set them and display the name of youngest student in the main function of another class named
student_demo.

6. Write a super class named furniture with member variables weight and price. From this furniture
class derive class named chair. These both super and sub classes have functions to set values of
their member variables. In another class, named furn_demo make objects of class chair and
display values of member variables of those objects.

Group “C”

7.What is exception? Explain ArrayIndexOutOfBoundsException with an example.
Ans: An exception is an event which occurs during the execution of a program that disrupts the normal flow of the program’s instructions. Java terminology, creating object and handling it to the runtime system called throwing an exception. The exception handler choosen is said to catch the exception.
ArrayIndexOutOfBoundsException: This is runtime exception. This exception is thrown to indicate that an array has been accessed with an illegal index. The index is either negative or greater or equal to the size of the array.
Let us consider the following program:

8.Write the steps required to create package with an example.

 

Leave a Reply

Your email address will not be published. Required fields are marked *