Skip to content

Latest commit

 

History

History

Test

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

PROJECT BASED LEARNING IN JAVA

Surprise Test 1


Question 1

Source Code: Box.java

Create a class Box that uses a parameterized method to initialize the dimensions of a box.(dimensions are width, height, depth of double type). The class should have a method that can return volume. Obtain an object and print the corresponding volume in main() function.

Question 2

Source Code: PrimeNumbers.java

Write a program to print prime numbers between 10 and 99.

Question 3

Source Code: MathOperation.java

Write a class MathOperation which accepts integers from command line. Create an array using these parameters. Loop through the array and obtain the sum and average of all the elements.

Display the result.

Check for various exceptions that may arise like ArithmeticException, NumberFormatException, and so on.

For example: The class would be invoked as follows:

C:>java MathOperation 1900, 4560, 0, 32500

Question 4

Source Code: LargestSmallest.java

Write a program to find the largest 2 numbers and the smallest 2 numbers in the given array.

Question 5

Source Code: DivisionOperator.java

Write a Program with a division method who receives two integer numbers and performs the division operation. The method should declare that it throws ArithmeticException. This exception should be handled in the main method.

Question 6

Source Code: Animals.java

Create a class named ‘Animal’ which includes methods like eat() and sleep().

Create a child class of Animal named ‘Bird’ and override the parent class methods. Add a new method named fly().

Create an instance of Animal class and invoke the eat and sleep methods using this object. Create an instance of Bird class and invoke the eat, sleep and fly methods using this object.

Question 7

Source Code: Colours.java

Write a program to print the color name, based on color code. If color code in not valid then print "Invalid Code". R->Red, B->Blue, G->Green, O->Orange, Y->Yellow, W->White.

Question 8

Source Code: PersonDetails.java

Write a program to accept name and age of a person from the command prompt(passed as arguments when you execute the class) and ensure that the age entered is >=18 and < 60.

Display proper error messages.

The program must exit gracefully after displaying the error message in case the arguments passed are not proper. (Hint : Create a user defined exception class for handling errors.)

Question 9

Source Code: StudentMarks.java

Write a Program to take care of NumberFormatException if user enters values other than integer for calculating average marks of 2 students. The name of the students and marks in 3 subjects are taken from the user while executing the program.

In the same Program write your own Exception classes to take care of Negative values and values out of range (i.e. other than in the range of 0-100)

Surprise Test 2


Question 1

Source Code: TreeSetCollection.java

Create Collection called TreeSet which is capable of storing String objects. The Collection should have the following capabilities

a)Reverse the elements of the Collection

b)Iterate the elements of the TreeSet

c) Checked if a particular element exists or not

Question 2

Source Code: PhoneNumbers.java

Write a program to create a HashMap to store name and phone number (Telephone book). When name is given, we can get back the corresponding phone number.

Question 3

Source Code: CopyingFile.java

File Copy

Write a program to copy from one file to another.

Sample Input and Output:

Enter the input file name

Input.txt

Enter the output file name

Output.txt

Question 4

Source Code: ArrayListNumbers.java

Create an ArrayList which will be able to store only numbers like int,float,double,etc, but not any other data type.

Question 5

Source Code: CharCountFile.java

File : Count Character

Write a program to count the number of times a character appears in the File. (Case insensitive... 'a' and 'A' are considered to be the same)

Sample Output:

Enter the file name

Input.txt

Enter the character to be counted

r

File 'Input.txt' has 99 instances of letter 'r'.

Question 6

Source Code: HashMapObjectExist.java

Create a Collection called HashMap which is capable of storing String objects. The program should have the following abilities:

a) Check if a particular key exists or not

b) Check if a particular value exists or not

c) Use Iterator to loop through the map key set

Surprise Test 3


Question 1

Answer: JSTL

How many tags are provided in JSTL? Explain any two.

Question 2

Source Code: FactorialJSP

Write a jsp program that prints a table with numbers and their corresponding factorial values.

Question 3

Answer: ServletLifeCycle

Diagrammatically explain the Servlet Life Cycle.

Question 4

Answer: Web Server Vs Application Server

With appropriate example mention the difference between web server and application server?