0% found this document useful (0 votes)
10 views

Computer Applications Test 2

Uploaded by

sarkar3subhamoy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Computer Applications Test 2

Uploaded by

sarkar3subhamoy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

+Computer Applications Test – B

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);

e. State the output of the following :


int [][]p = { { 2,3,4},{5,6,7},{8,9,10}};
System.out.println(a[1][2] * a[0][1]);
System.out.println(Math.sqrt(a[2][1]);
Question 4
a. Complete the table given below: [5]

Data Type Default value Bytes occupied


Byte
Float
int
Boolean
Char ‘\u0000’
Arup Sir @ 9832064034 || Computer Applications || Page 1 of 3
b. State the output :
int i= 4 ;
do
{
i++;
if( i%3 == 0)
continue;
if( i>20)
break;
System.out.println(i);
} while(true);
SECTION B
Question 5
Write a program to ask the user to enter any sentence and print the consecutive pairs of vowels present
in the sentence. [15]
Question 6
Design a class to overload a function Series ( ) as follows :
i. double Series ( double n) – it returns the sum of the series
1 4 7 10
sum = 2 + 5 + 8 + 11 +… … … … … … …upto n terms
a a a a
ii. double Series(double a , double n) – it returns the sum of the series
1 1 1 1
sum = − + − + …upto n terms
2 4 6 8
iii. double Series ( int n) – it returns the sum of the series
sum = 1 + (1x2) + (1X2x3) + ( 1x2x3x4) +…………………… + ( 1x2x3x4x5x……xn) [15]

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]

Arup Sir @ 9832064034 || Computer Applications || Page 3 of 3

You might also like