COMPUTER APPLICATIONS
------------------------------------------------------------------------------------------------------------
Max
Marks: 50
ALL
QUESTIONS ARE COMPULSORY
The
marks intended for questions are given in brackets [ ].
-------------------------------------------------------------------------------------------------------------------
Select
the correct option for each of the following questions
------------------------------------------------------------------------------------------------------------
.
SECTION A (30 Marks)
Question
1
Choose the correct answer [5×1=5]
(1) Arrange
the operators given below in order of lower precedence to higher precedence:
i) && ii)
-- iii) % iv) ( )
a) (iv), (i), (iii), (ii)
b)
(iii), (i), (ii), (iv)
c)
(i), (iii), (ii), (iv)
d)
(iv), (ii), (iii), (i)
(2) Which
keyword is used to represent the currently calling object?
(a)
new
(b)
this
(c)
return
(d)
all of these
(3) Exit
controlled loop is------------?
(a) do while
(b) while
(c) for
(d) if else
(4)
What is the final value stored in variable x ?
double
a =-15.7;
double
x = Math.abs(Math.ceil(a));
(a) 16.0
(b) 15.0
(c) 16
(d) 15
(5)
Name the type of error in the statement given below:
int a;b;c;
(a) Syntax
(b) Runtime
(c) Logical
(d) None
of the above
Question
2
Fill
in the blanks with the correct option [5×1=5]
(6)
----------- is an act representing essential features without including
background details.
(a)
Inheritance
(b)
Abstraction
(c)
Encapsulation
(d)
Polymorphism
(7)
The number of bytes occupied by double data type is __________byte/s
(a)
4
(b)
8
(c)
2
(d)
None
(8) Which of the following is not a Java
reserved word(keyword)?
(a) private
(b) void
(c)break
(d) total
(9)
Name the package that contains the Scanner class
(a)
java.util
(b) java.io
(c) java.lang
(d) java.awt
(10)
Method that accepts a string including space is _______
(a)
next()
(b)
nextInt()
(c)
nextLine()
(d)
None of the above
Question
3
Name
the following
[5×1=5]
(11)
The wrapper class to which the method parseFloat() belongs to
(a) Float
(b) double
(c) float
(d) ParseFloat
(12)
Write the equivalent Java statements for the following expressions
(a) math.sqrt((b*b)-(4*a*c))/2*a;
(b)
Math.sqrt((b*b)-(4*a*c))/2*a;
(c) Math.sqrt(b*b - 4*a*c/2*a);
(d)
Math.Sqrt((b*b)-(4*a*c))/2*a;
(13)
A constructor without any argument is known as
(a)
Constructor
(b)
Parameterized constructor
(c)
Function
(d)
Default constructor
(14) The prototype of a function Show( ) which receives a float value n and an
integer m and returns true or false
(a) void Show(float n,int m)
(b)boolean Show(char n,float m)
(c) boolean Show(float n,int m)
(d) void show(int m,float n)
(15)
Parameters used in the function definition are called
(a)
forward parameter
(b)
actual parameter
(c)
formal parameter
(d)none
of the above
Question 4
State True Or False [5×1=5]
(16)
char ch=(char)120; Type of casting is Implicit type casting.
(a)
True
(b)
False
(17) ! (4>3&&7>8)
(a)
True
(b) False
(18)
The access specifier that gives the most accessibility is public
(a)
True
(b) False
(19)
The break statement mayn’t be used in a switch statement.
(a)
True
(b) False
(20)
The statement p=-5 means p=p-5.
(a)
True
(b) False
Question
5
Choose
the odd one
[5×1=5]
(21)
(a)
Polymorphism
(b)
Inheritance
(c)Procedure
(d)Encapsulation
(22)
(a)
||
(b)
!=
(c)
<=
(d)
>
(23)
(a)The
constructor is automatically called while creating an object
(b)
The constructor is always public
(c)
A constructor is overloaded automatically
(d)
The constructor is defined with not the same name as class name.
(24)
(a)
float
(b)
long
(c)
boolean
(d)
Class
(25)
(a)
//comment
(b)*/comment
(c)/**comment*/
(d)/*comment*/
Question
6
Give
the output of the following [5×1=5]
(26)
y + =++y + y-- + --y; when int y=8
(a)
32
(b)
31
(c)
25
(d)
33
(27)
If a user wants to execute a loop 10 times, which of the following statement
will be used.
(a)
for (i=6; i<=26; i=i+2)
(b)
for (i=3; i<=30; i=i+3)
(c)
for (i=0; i<10; i++)
(d)
All of the above
(28)
String x = (rating >=5) ? "Super Hit" : "Flop"; when a =6
(a)
Flop
(b)Super
Hit
(c)SuperHitFlop
(d)none
(29) switch ( x )
{
case 'a' : System.out.println("Water");
case 'b' : System.out.println ("Boiling Water");
break;
case 'c' : System.out.println("Water Vapour");
default : System.out.println("Not Water");
}
when x='B'
(a) Bioling
Water
(b) Water
(c) Not
Water
(d) Water
Vapour
(30)
int x=10, y=200;
while(x<=y)
{
y=y/x;
}
System.out.println(y);
How many time the loop is executed and what is
the output?
(a)
Loop is executed 2 times and the output is 2
(b)
Loop is executed 3 times and the output is 2
(c)
Loop is executed 2 times and the output is 20
(d)
Loop is executed 1time and the output is
20
SECTION B (20 Marks)
Question
7 [6x1=6]
Given below is a class with the following specifications:
(i) void series(int n): to display the sum of the series given
below:
1 +5 +9 +……………………. … +n terms
(ii) double series(int a,int x): to display the sum of
the series given below:
1/a2 + 3/a6 +5/a10 +
……………….. + x terms
class Overload
{
double sum = (31)……………;
public void
series((32)………………..)
{
int b=1;
for(int
i = 1; i <= n; i++)
{
sum=sum+b;
b=(33)……………………….;
}
System.out.println("Sum
of series is " + sum);
}
public double (34)……………..(int a,int x)
{
int c=1,d=2;
for(int i = 1;
i<=n; i++)
{
sum=sum+(
double)c/( 35)…………………….;
c=c+2;
d=d+4;
}
(36)………………….
}
}
Fill in the blanks of the given program with appropriate java statements
(31)
(a) 1
(b) 2
(c) 0
(32)
(a) int
a
(b) int n
(c) int a
(33)
(a) b+4
(b) b+3
(c) b+2
(34)
(a) Series
(b) Overload
(c) series
(35)
(a) Math.pow(a,d)
(b) math.pow(a,c)
(c) Math.sqrt(a,d)
(36)
(a) Return sum;
(b) return sum;
(c) System.out.println(sum)
Question 8: [6x1=6]
The following program is based on the specification given below.
Fill in the blanks with appropriate java statements.
class: ElectricBill
Instance Variable/ data member: |
|
String n |
to store the name of the customer |
int units |
to store the number of units consumed |
double bill |
to store the amount to paid |
Member methods:
void accept() – to accept the name of the customer and number of
units consumed
void calculate() – to calculate the bill as per the following
tariff :
Number of units Rate per unit
First 100 units Rs.2.00
Next 200 units Rs.3.00
Above 300 units Rs.5.00
A surcharge of 2.5% charged if the number of units consumed is
above 300 units.
void print() – To print the details as follows :
Name of the customer ………
Number of units consumed ……
Bill amount …….
void main(): to create an object of the class and call the above
member methods.
import java.util.Scanner;
class (37)__________
{
String n;
int units;
double bill;
public
void accept()
{
Scanner
sc = new Scanner((38)__________);
System.out.print("Please
Enter name: ");
n
= (39)_________;
System.out.print("Please
Enter units: ");
units
= sc.nextInt();
}
public
void calculate()
{
if
(units <= 100)
{
bill = units * 2;
}
else
if (units <= 300)
{
bill = 100 * 2 + ((40)______) * 3;
}
else
{
bill = 100 * 2 + 200 * 3 + (units -
300) * 5;
double surcharge =(41)_________;
bill
= bill + surcharge;
}
}
public
void print()
{
System.out.println("Name
of the customer is" + n);
System.out.println("Number
of units consumed is " + units);
System.out.println("Bill
amount is " + bill);
}
public
static void main()
{
ElectricBill
obj = new ElectricBill();
obj.accept();
(42)_________;
obj.print();
}
}
(37)
(a) Class
(b) electric bill
(c) ElectricBill
(38)
(a) system.in
(b) System.in
(c) Scanner
(39)
(a) sc.nextline()
(b) sc. nextLine()
(c) Sc. NextInt()
(40)
(a) units+100
(b) units –100
(c) unit
(41)
(a) bill * 3.5 / 100
(b) bill*4.5/100
(c) bill * 2.5 / 100
(42)
(a) obj.calculate()
(b) calculate.obj()
(c) obj.ElectricBill()
Question 9 [4x1=4]
Fill in the blanks with appropriate code for proper working of the function arm().
The function will receive a number and check whether the number is an
Armstrong number or
not and display message accordingly.
(Armstrong Number is a number whose sum of cubes of the digits is equal to
the number.Eg:- 153=13+53+33)
class Armstrong
{
public void arm(int n)
{
int n1=n,sum=0,d;
while((43)----------------)
{
d=n%10;
sum=sum+(44)------------------;
n=n/(45)---------------;
}
if((46)-----------)
System.out.println(“Armstrong number”);
else
System.out.println(“Not Armstrong number”);
}
}
(43)
(a)
n<0
(b)
n>0
(c)
n==0
(44)
(a)
d+d+d
(b)
d*d
(c)
d*d*d
(45)
(a)
10
(b)
9
(c)
100
(46)
(a)
sum==n
(b)
sum==d
(c)
sum==n1
(47) Name the movement of control from one line to other in a program
(a)
Control the flow
(b) Flow of
Control
(c)
Controlling the flow
(d) None of the above
and where the control executes the next case.
(a) Through the Fall
(b) Falling through
(c)
Failing through
(d) Fall Through
(49) The case which gets executed when the value doesn't match with any of the cases
listed in the switch case
(a) By default case
(b) default
(c) return
(d)Return
of the 2
blocks of statement based on given
condition.
(a) if statement
(b) while
loop
(c) for
loop
(d) switch
case