Computer Applications Test 2
Computer Applications Test 2
Question 1 ( 5 x 2 = 10)
a. What is the purpose of the:
i. new keyword
ii. this keyword
b. State the difference between a constructor and a method.
c. What is meant by operator associativity?
d. Give examples of the non-numeric primitive data types.
e. Differentiate between protected and private access specifiers.
Question 2 ( 4 x 2 = 8)
What is a function prototype and function signature?
a. What is meant by fall through?
b. Write a java statement to check if the 10th element of an array X[15] is divisible by 5.
c. Using ternary operators write a code to print the maximum of any three numbers.
d. Write the prototype of a function Merging which takes three arguments – a string and a character
and a double value and returns a Boolean value.
Question 3 ( 5 x 2 = 10)
a. Rewrite the following code without using logical operators:
If(a>b&& a>c)
System.out.println(a);
b. Write the following expression in Java:
√3 x +b 2
a5 +b
c. What will be the value of y- = y++ * 2 + ( y-- * --y) * 3 + y ; if y = 7 before evaluation.
d. State the output of the following :
int a = 10 , b = 20 , i;
for(i=1;i<=15;i+=5)
a++; ++b;
System.out.println(a + “ and ” + b);
Question 7
The basic salary of employees is undergoing a revision. Define a class called Grade_Revision with the
following specifiations:
Instance variables / data members
String name – to store the name of the employee
int bas - to store basic salary
int expn – to consider the length of service of an employee
double inc – to store increment
double nbas – to store new basic salary (basic + increment)
Member methods :
Grade_Revision : constructor to initialize all data members
void accept ( ) – To input name, basic and experience.
void increment( ) – to calculate increment with the following specifications:
Experience Increment
Upto 3 years Rs 1000 + 10% of basic
4 years – 5 years Rs 3000 + 12% of basic
6 years – 10 years Rs 5000 + 15% of basic
More than 10 years Rs 8000 + 20% of basic
Arup Sir @ 9832064034 || Computer Applications || Page 2 of 3
void display( ) – to print all the details of the employee.
Write a main method and create an object of the class and call the above member methods. [15]