Annai Vailankanni College of Engineering: Part B (40 Marks) 1

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

ANNAI VAILANKANNI COLLEGE OF ENGINEERING

AVK Nagar, Pothaiyadi Salai,Pottalkulam,Azhagappapuram P.O., Kanyakumari District, Tamil Nadu – 629 401.

S5 – Information Technology
First Internal Assessment Test
IT51 - Java Programming

Duration: 11/2hrs Max.Marks: 50


Part A(5x2=10 Marks)

1. What is the purpose of using this keyword? Give an example.


2. Write a short note on finalize() method.
3. What is meant by polymorphism in OOP?
4. Distinguish between public, private and protected?
5. Why two classes are used to handle Sting in java?

Part B(40 Marks)

1. The employee list for a company contains employee code, name, designation and basic pay. The employee is given
a house rent allowance (HRA) of 10% of the basic pay and dearness allowance (DA) of 75% of the basic pay. The
total pay of the employee is calculated as Basic Pay+HRA+DA. Write a class to define the details of the employee.
Write a constructor to assign the required initial values. Add a method to calculate HRA, DA and total pay and
print them out. Write another class with a main method. Create objects for three different employees and
calculate the HRA,DA and total pay. (16)
(OR)
2. Explain the following with suitable example
a. Constructor (8)
b. Passing an object as a method parameter (8)
3. A mark list contains reg_no. and marks for three subjects sub1,sub2 and sub3. Write a class to define the mark
list. Write a constructor to initialize all the variables. Write a method called Result(int minmark) where, minmark
indicates the minimum mark for “pass” for each subject. This method will declare a candidate as “Pass”, if the
candidate secures marks in each subject greater than or equal to min. Write another overloading method
Result(int minmark,int meritmark), where meritmark indicates that a candidate who gets a “Pass” and average
of the three subjects equal to or greater than merit is eligible for getting a scholarship. Write another class with
main method and try the method for 7 different candidates to determine whether they get “Pass” and also
determine whether they are eligible for scholarship. (16)
(OR)
4. List out the basic concept of oops? Explain. (16)
5. Give brief notes about String class and its methods. (8)

(OR)
6. Write a program to arrange five students name in an alphabetical order. The students name may be given by a
user. (8)
ANNAI VAILANKANNI COLLEGE OF ENGINEERING
AVK Nagar, Pothaiyadi Salai,Pottalkulam,Azhagappapuram P.O., Kanyakumari District, Tamil Nadu – 629 401.

S5 – Information Technology
First Internal Assessment Test- Answer key
IT51 - Java Programming
Part-A
1. What is the purpose of using this keyword? Give an example.

This keyword is used to refer the object which invoked the method. This keyword can be used inside any
method to refer to the current object. That is, this always has reference to the object on which the method was
invoked. Normally a method is called with two types of arguments implicit. Implicit arguments is assigned to this
Example
void change_val(int Num1,int Num2)
{
this.Num1 = Num1;
this.Num2=Num2;
}
2. Write a short note on finalize() method.
Finalize method is similar to destructor in c++. But manual memory reclamation is not needed, because java
does automatic garbage collection.
In some situations, objects utilize a resource other than memory, such as a file or a handle to another object
that uses system resources, when it is no longer needed.
The finalize method will be called before the garbage collector removes the object
Only one finalize can be defined to a class
3. What is meant by polymorphism in OOP?
Polymorphism is the ability of an object to take on many forms. The most common use of
polymorphism in OOP occurs when a parent class reference is used to refer to a child class object.
4. Distinguish between public, private and protected?
Public is signifies that the methods or variable can be accessed by elements residing in other classes. Private
signifies that the method or variable can only be accessed by other elements of its class. Protected signifies
that the methods or variable can only be accessed by elements residing in its class, subclasses in the same
package.
5. Why two classes are used to handle Sting in java?
The java platform provides two classes, String and StringBuffer, that store and manipulate strings-character
data consisting of more than one character. The String class strings for strings whose value will not change.
The StringBuffer class provides for strings whose value will be modified; you use string buffers when you know
that the value charcter data dynamically.

Part-B
1. The employee list for a company contains employee code, name, designation and basic pay. The employee is
given a house rent allowance (HRA) of 10% of the basic pay and dearness allowance (DA) of 75% of the basic
pay. The total pay of the employee is calculated as Basic Pay+HRA+DA. Write a class to define the details of
the employee. Write a constructor to assign the required initial values. Add a method to calculate HRA, DA
and total pay and print them out. Write another class with a main method. Create objects for three different
employees and calculate the HRA,DA and total pay.
HRA calculation – 3 marks
Da Calculation – 3 marks
Total pay calculation – 3marks
Constructor – 3 marks
Main method & Object creation – 4 marks
(OR)
2. Explain the following with suitable example
a. Constructor
Definition - 3 marks
Syntax - 3 marks
Example - 2 marks
b. Passing an object as a method parameter (8)
Explanation - 2 marks
Syntax - 2 marks
Example - 4 marks
3. A mark list contains reg_no. and marks for three subjects sub1,sub2 and sub3. Write a class to define the
mark list. Write a constructor to initialize all the variables. Write a method called Result(int minmark) where,
minmark indicates the minimum mark for “pass” for each subject. This method will declare a candidate as
“Pass”, if the candidate secures marks in each subject greater than or equal to min. Write another
overloading method Result(int minmark,int meritmark), where meritmark indicates that a candidate who
gets a “Pass” and average of the three subjects equal to or greater than merit is eligible for getting a
scholarship. Write another class with main method and try the method for 7 different candidates to
determine whether they get “Pass” and also determine whether they are eligible for scholarship.
(16)

Result(int minimark) - 3 marks


Result(int minmark,int meritmark) - 3 marks
Main class with 7 object - 5 marks
Constructor - 3 marks
Explanation - 2 marks

(OR)
4. List out the basic concept of oops? Explain. (16)

Object – 2 marks
Class – 2 marks
Inheritance – 2marks
Data Abstraction and Encapsulation – 2marks
Polymorphism – 2marks
Dynamic Binding – 2marks
Message Passing – 2marks
Example – 2marks

5. Give brief notes about String class and its methods. (8)

Explanation – 2marks
Any five methods with explanation – 6 marks
(OR)
6. Write a program to arrange five students name in an alphabetical order. The students name may be given by
a user. (8)

Main class – 2marks


Method to arrange in an order – 4marks
Display the result – 2marks

You might also like