Sample Question Paper 1
COMPUTER APPLICATIONS
Maximum Marks: 50
Time allowed: One hour (inclusive of reading time)
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]
1)The default return type of a User defined function is
(a) float
(c) Void
(b) int
(d) Null
2) A constructor
(a) Must have the same name as the class it is declared within.(b) Is used to create objects.(c) May be declared private(d) All of above
3) Default value of int data type is
(a) 0(c) 0.0
(b) 1
(d) Null
4) How many times 'Hello' is printed ?
public static void main(String args[]) {
for(i=0;i<5;i++){
System.out.println("hello");
break;
}
}
(a) 5
(c) 4
(b) 1
(d) 0
5) The keyword used to return a value from a function is:
(a) returns
(c) send
(b) return
(d) None
Question 2) Fill in the blanks with the correct option [5×1]
1) Multiple branches is used by __________ statement
(a) Break
(b) Switch
(c) Continue
(d) Loop
(a) Assembler language(b) Byte code(c) Bit code(d) Machine code
3) What is the result of 12 % 10 = _________
(a) 1
(b) 2(c) 12(d) 0
4) Byte Data Type range is _________
(a) -127 to 128
(b) -128 to 128
(c) -127 to 127
(d) -128 to 127
5) A _________ class is accessible both inside and outside a package.
(a) public
(b) protected
(c) Super class
(d) open
(a) public
(b) protected
(c) static
(a) Java.io
(b) Java. lang
(c) Java .math
3) A Scanner class method which is used to input real number
(a) nextFloat( )
(b) nextChar( )
(c) nextReal( )
4) A primitive data type which is used to store true or false value.
(a) String
(b) boolean
(c) int
5) A operator type which is used for comparison
(a) Arithmetic Operator
(b) Increment Operator
(c) Relational Operator
Question 4) State True Or False [5×1]
1) Math.ceil() is an user defined function
(a) True
(b) False
(a) True(b) False
3) The default return type for a User defined function is Boolean
(a) True
(b) False
4) Encapsulation adds the function in a user-defined structure.
(a) True
(b) False
5) next( ) method is used to input more than two strings from the user.
(a) True
(b) False
Question 5) Choose the odd one [5×1]
1)
(a) Use of pointers
(b) Dynamic
(c) Object-oriented
(d) Secured
(a) System(b) Object(c) Main(d) strictÃp
(a) int var;(b) int VAR:(c) int 1 var;(d) int varl;
(a) next( )
(b) nextInt( )
(c) pow( )
(d) nextFloat( )
5)
(a) <=
(b) +
(c) /
(d) ++
(a) America(b) London(c) No output
(a) 75(b) No output(c) 80
(a) 23(b) 24(c) 25
4) If int x = 15, y = 20 then what will be the value of x
x = ( x < y) ? (y + x) : ( y - x) ;
(a) 5
(b) 25
(c) 35
5) Math.floor (46.6) output is ?
(a) 46.6
(b) 46.0
(c) 47.0
SECTION B (20 Marks)
Question 7) Fill in the blanks of the given program with appropriate java statements [6×1]
Given below is a class with the following specifications:
Class name : SumNum
Member Methods:
void sum ( ) – to print the sum of the following series :
sum ( ) = 1 - 2 + 3 - 4 + 5 - 6 + 7 - 8 + 9 - 10
void sum(int m , int n) – to calculate sum of number between [m,n]
sum( 4,6) = 4 + 5 + 6
Fill in the blanks of the given program with appropriate java statements –
class SumNum
{
void sum ( )
{
int k;
int sum = 0;
for ( k = 1 ; (a)_________; k++)
{
if((b)___________)
(c)__________;
else
(d)__________;
}
System.out.println(sum);
}
void sum( int m, int n)
{
int sum = 0;
for((e) ________ : (f)_______; i++)
sum = sum + i;
System.out.println(sum);
}
}
(a)
1. k < 10
2. k < = 10
3. k > 10
(b)
1. k % 3 == 0
2. k % 2 == 0;
3. k % 2 == 1;
(c)
1. sum = sum + k ;
2. sum = sum - k ;
3. sum = sum + 1 ;
(d)
1. sum = sum + k ;
2. sum = sum - k ;
3. sum = sum + 1 ;
(e)
1. int i = n
2. int i = m
3. int i = 1
(f)
1. i < = m
2. i < = n
3. i < = 10
Question 8) Fill in the blanks of the given program with appropriate java statements [6×1]
The following program is based on the specification given below.
Fill in the blanks with appropriate java statements.
class name : Student
member variables : String studentName [Name of the Student]
int marks [ Marks obtained ]
char grade [ grade awarded ]
Member methods :
void enterMarks( ) – to enter name of student and assign marks to the student through keyboard
void print() – to print the student name and marks assigned
void awardGrade() – grade is awarded to the student based on his/her marks.
Marks range Grade
○ Greater than 91 A
○ Greater than or equal to 80 B
○ Greater than 70 C
○ Greater than 50 D
○ Less than 50 F
void main ( ) – to create an object of the class and invoke the methods of the class
class Student
{
String studentName; int marks ; char grade;
Scanner s= new Scanner(System.in);
void enterMarks( )
{
System.out.println(“Enter Number of the Student”);
studentName = (a)___________;
System.out.println(“Enter the marks obtained“);
marks = (b) ____________ ;
}
void awardGrade()
{
if ( marks > 91)
grade = ‘A’;
(c)______________
grade = ‘B’;
else if(marks > 70)
grade = ‘C’;
else if(marks > 50)
grade = ‘D’;
(d) ________
grade = ‘F’;
}
void print()
{
System.out.println(“Student Name = ”+studentName);
(e)_______________________ ;
}
void main ()
{
Student s = new Student();
(f)____________;
s.awardGrade();
s.print();
}
}
(a)
1. s.next()
2. s.nextLine()
3. s.next().charAt(0)
(b)
1. s.next()
2. s.nextLine()
3. s.nextInt()
(c)
1. else if(marks >80)
2. else if ( marks > = 80 )
3. else if( marks > 70 )
(d)
1. else if ( marks > 50)
2. else if ( marks > 50)
3. else
(e)
1. System.out.println(“Marks obtained :”+marks) ;
2. System.out.println(“Student is excellent”);
3. System.out.println(“Student is bad”) ;
(f)
1. s.enterMarks()
2. s.enterInput()
3. s.awardGrade()
Question 9) Fill in the blanks of the given program with appropriate java statements [4×1]
The following program is based on the specification given below.
Fill in the blanks with appropriate java statements.
class name: hello
we have first initialized the two variables i and k with the values 2 and 1 respectively, while loop is used with the condition ++ i < 6. Thus, the value of i will increase by 1 before it can be used further because of a preceding ++ operator in the condition then assignment operator will be used between k and i. So the value of k will become 3.this will continue till the value of k will become 60.
class ____(a)____{
public static ____(b)____main (String args[])
{
int i = ____(c)____, k=1;
while (++i < 6)
____(d)____
System.out.printin(k);
}
}
(a)
(i) hello
(ii) class
(iii) void
(b)
(i) class
(ii) void
(iii) object
(c)
(i) i = 1
(ii) i = 2
(ii) i = 0
(d)
(i) k * = i;
(ii) i * = k;
(iii) k = i;
Question 10) Case Study [4×1]
Java offers a rich set of operators to manipulate variables. Operator in Java is a symbol that is used to perform operations. For example: +, -, *, / etc. Operators are special symbols that execute specific operations on one, two, or three operands and then return a result. Operators with higher precedence are evaluated before operators with relatively lower precedence. Operators on the same line have equal precedence. When operators of equal precedence seem in a similar expression, a rule must govern, which is assessed first. Entirely binary operators except for the assignment operators are assessed from left to right; assignment operators are evaluated right to the left. *= is an assignment operator. It uses ternary an arithmetic operator like +, -, *, or /, and the assignment operator (a single '=').
(a)
int k=1,i=2
while (++i<6)
k*=i;
System.out.println(k);
Predict the output
(i) 30
(ii) 60
(iii) 20
(iv) 50
(b) k*-i; is equal to
(i) k = k * i;
(iii) k = k - i;
(ii) k = k + i;
(iv) k = k/i;
(c) ++ is a ______
(i) Increment operator
(ii) Decrement operator(iii) Arithmetic operator(iv) None of the above
(i) short(ii) int(iii) long(iv) all of the above