Computer Assesment I QP
Computer Assesment I QP
Section A
Question 1:
1. Name the following: [2]
a. an operator which implements polymorphism.
b. keyword used for instantiation.
2. Why a class is called an object factory? [2]
3. Write one difference between / and % operator. [2]
4. Name and give example for each: [2]
a. entry-controlled loop
b. exit controlled loop.
5. State the difference between Constructor and Method. [2]
Question 2:
1. What is Function Signature? Give Example. [2]
2. Write a return type for the following methods- a. charAt ( ) b. lastIndexOf ( ) [2]
3. State the methods of String Initialization with example. [2]
4. Write a java expression for the following. [2]
√(𝑎−𝑏)𝑥+𝑐
𝑠= 𝜋+𝑏
5. Rewrite using conditional operator: [2]
if(x= =50)
amount=500;
else
amount=10.0/100*x;
Question 3:
1. Give the output of the following string functions: [2]
a. “ACHIEVEMENT”.replace(‘E’,‘A’)
b. “DEDICATE”.compareTo(“DEVOTE”)
3. Solve the following expressions and give the of a, b and c. Consider a=3, b=4, c=6; [2]
a+= ++a*b++ /c++ + b++;
4. Give the output of the following program segment and also mention the number of times
the loop is executed: [2]
String s = “Examination”;
int n = s.length();
System.out.println(s.substring(5, n)).toUpperCase());
System.out.println(s.charAt(2) == s.charAt(6));
8. Write function prototypes for the following: [1]
a. Private access method sum which accepts three int type variables as parameters and
return a float type.
{
int num1,num2;
Test()
{
System.out.print("1");
new Test(10);
System.out.print("5");
}
Test(int temp)
{
System.out.print("2");
new Test(10, 20);
System.out.printf("4");
}
Test(int data, int temp)
{ num1=data;
num2=temp;
System.out.print("3");
}
void sum() // method 1
{
System.out.println(“Ans:”+(num1+num2));
}
A courier company charges differently for 'Ordinary' booking and 'Express' booking based on the weight
of the parcel as per the tariff given below:
Write a program to input weight of a parcel and type of booking (`O' for ordinary and 'E' for express).
Calculate and print the charges accordingly.
Question 2: [15]
Write a menu driven programs to do the following:
i. 1
12
123
1234
12345
ii. to accept a number from the user and check whether it is a Palindrome or not.
Also display the sum of digits and its average.
Question 3: [15]
Define a class called Mobike with the following description: Instance variables/ Data
members:
bno : to store the bike’s number
phno : to store the phone number of the customer
name : to store the name of the customer
days : to store the number of days the bike is taken on rent
charge : to calculate and store the rental charge
Member methods:
Mobike() : default constructor to initialize the data members with default values.
void input () : to input and store the detail of the customer.
Question 4: [15]
Design a class to overload a function series( ) as follows:
1. double series(double n) with one double argument and returns the sum of the series.
sum = (1/1) - (1/2) + (1/3) - .......... + (1/n)
2. double series(double a, double n) with two double arguments and returns the sum of the
series.
sum = (1/a2) + (4/a5) + (7/a8) + (10/a11) + .......... to n terms
Question 5: [15]
Special words are those words which start and end with the same letter.
Example: EXISTENCE, COMIC, WINDOW
Palindrome words are those words which read the same from left to right and vice-versa.
Example: MALYALAM, MADAM, LEVEL, ROTATOR, CIVIC
All palindromes are special words but all special words are not palindromes.
Write a program to accept a word. Check and display whether the word is a palindrome or only a
special word or none of them.
Question 6: [15]
Write a program to assign a full path and file name as given below. Using library functions,
extract and output the file path, file name and file extension separately as shown.
Input: C:\Users\admin\Pictures\flower.jpg
Output Path: C:\Users\admin\Pictures\
File name: flower
Extension: jpg