0% found this document useful (0 votes)
70 views7 pages

Computer Preboard

This document is a pre-board examination paper for Computer Science, consisting of two sections: Section A with multiple-choice questions and Section B requiring programming tasks. Section A contains 20 questions worth 40 marks, while Section B includes 8 programming questions worth 60 marks, covering topics such as Java programming, data structures, and object-oriented principles. Students are instructed to attempt all questions from Section A and any four from Section B.

Uploaded by

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

Computer Preboard

This document is a pre-board examination paper for Computer Science, consisting of two sections: Section A with multiple-choice questions and Section B requiring programming tasks. Section A contains 20 questions worth 40 marks, while Section B includes 8 programming questions worth 60 marks, covering topics such as Java programming, data structures, and object-oriented principles. Students are instructed to attempt all questions from Section A and any four from Section B.

Uploaded by

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

10 Computer

Pre-board 16/1/25 100 2

This paper is divided into two Sections. Attempt all questions from Section A and any four
questions from Section B. The intended marks for questions or parts of questions are given
in brackets [ ].
Section A (40 Marks)
(Attempt all questions from this Section.)
Question 1 [20]
Choose the correct answers to the questions from given options.
(Do not copy the questions, write the correct answers only.)

(i) Which of the following is correct for above picture?


a. abstraction b. encapsulation c. inheritance d. polymorphism
(ii) int x=0,y=0,z=0;
x=(++x +y--)*z++;
a. 0 b. 1 c. 2 d. None of these
(iii) The character class which checks whether a character given as argument is a blank
space or not:
a. Character.isBlankSpace(ch) b. Character.toBlankSpace()
c. Character.isWhiteSpace(ch) d. Character.hasWhiteSpace(ch)
(iv) What is the default size of double datatype?
a.8 b. 16 c. 32 d. 64
(v) What is the correct syntax to call a method named “myMethod” from an object
myobject”?
a. myobject.myMethod(); b. myMethod.myobject();
c. myMethod(); d. myobject.myMethod;
(vi) What will be the output of the following java code?
char array_variable [] = new char[10];
for (int i = 0; i < 10; ++i)
{ array_variable[i] = 'i';
System.out.print(array_variable[i] + "");}
a. 1 2 3 4 5 6 7 8 9 10 b. 0 1 2 3 4 5 6 7 8 9 10
c. i j k l m n o p q r d. i i i i i i i i i i
(vii) The output of the statement of “TIGER”. indexOf(‘S’) is:
a. 3 b. 2 c. -1 d. 0
(viii) char a[]={‘0’,’1’,’2’,’3’,’4’,’5’};
Write the output of the following statements: int c=(int)((a[2])-48)*10);
a. 20 b. -460 c. ‘2’-48 d. error
(ix) To print the 02468 which of the following is correct?
a. for(int i=1;i<=10;i+=2) {System.out.print(i);}
b. for(int i=2;i>=10;i+=2){System.out.print(i);}
c. for(int i=0;i<10;i+=2) ){System.out.print(i);}
d. for(int i=10i>=2;i-=2){System.out.print(i);}
(x) The method which do not changes the state of an object is called:
a. pure b. impure c. replace d. none
(xi) Parameters used in method prototype statement are also called ____ parameters.
a. defined b. actual c. formal d. passed
(xii) Which of the following returns a character?
a. “xyz”. indexOf(‘x’) b. “xyz”. replace(‘x’,’y’)
c. “xyz”.charAt(0) d. “xyz”. length()
(xiii) The output of the following code is:
System.out.println(Math.rint(4.5)+Math.round(4.5));
a. 10.0 b. 10 c. 9.0 d. 9
(xiv) In OOP stress is laid on:
a. data b. class c. function d. object
(xv) Which of the following creates individual copy for all objects?
a. instance variable b. local variable c. static variable d. All of these
(xvi) Consider the following program segment in which the statements are jumbled,
choose the correct order of statements to search for a given element using linear
search technique.
void lsearch (int a[], int b)
{
int f=0; ------------ 1
if(b==a[i] ) ------------ 2
for(int i=0;i<a.length;i++) { ------------ 3
f=1;break}} ------------ 4
a. 1,2,3,4 b. 4,1,3,2 c. 1,3,2,4 d. 4,3,2,1
(xvii) Assertion(A): Integer.parseInt("123") creates an Integer object.
Reason(R): The parseInt method of the Integer class returns a primitive int value.
a. Both Assertion (A) and Reason (R) are true and Reason (R) is a correct
explanation of Assertion (A)
b. Both Assertion (A) and Reason (R) are true and Reason (R) is not a correct
explanation of Assertion (A)
c. Assertion (A) is true and Reason (R) is false
d. Assertion (A) is false and Reason (R) is true
(xviii) What is the value of the expression 5+2==7&&4>3 in java?
a. 1 b. true c. 0 d. false
(xix) Which component is used to compile, debug and execute the java programs?
a. JDK b. JRE c. JVM d. JIT
(xx) What will be the output of:
System.out.println(Math.rint(-9.4)+Math.sqrt(9.0));
a. -5.0 b. -6.0 c. -6.4 d. -5.4
Question 2 [20]

(i) Name the following:


(a) A Character method that checks whether a character is white space or not.
(b) A Math method which can have two arguments and returns double data type.
(ii) Give the difference between Instance variable and class variable.
(iii) Write the output of the following string methods
String x=”Genes”,String y=”Engineering”;
a. String z= (x.substring(0,4)+”tic”.concat(y)).toUpperCase();
b. System.out.println(z.compareToIgnoreCase(y));
(iv) What will be the output for following code?
char b=’5’;
int n=(int)b+13;
System.out.println ((char)n+” ,”+n); (iv)
(v) Which are the types of inheritance?
(vi) A student is trying to display the ascii values of the alphabets stored in a character
array, However the code has an error. Name the error(syntax/logical/runtime).
Correct the code so that it compiles and runs correctly.
char ch[]={‘a’,’1’,’3’,’A’,’$’};
for(int i=0;i<=ch.length();i++)
{ if(ch[i].isAlpha())
{ System.out.println((int)ch[i]);}}
(vii) class Shape
{ void area(int l,int b)
{int r=l*b; System.out.println(r);}
int area(int s)
{ return s*s; }
public static void main(String args[])
{ Shape ob = new Shape();
ob.area(12,45);
System.out.println((ob.area(40)); }}
a. Name the constructor in the above program.
b. Name the oop’s principle depicted in the above program.
(viii) Give the value of y for y+= ++y +y-- +--y, when y=8.
(ix) Give the difference between User defined data type and primitive data type.
(x) Write the following code using ternary operator.
double tax;
if(amt<=10000)
tax=500;
else
tax=700;
Section B (60 Marks)
(Answer any four questions from this Section.)
The answers in this section should consist of the programs in either BlueJ environment
or any program environment with java as the base.
Each program should be written using variable description / mnemonic codes so
that the logic of the program is clearly depicted.
Flowcharts and algorithms are not required.
Question 3 [15]
International Tours and Travels Company has introduced a new tour packages to the
different countries from India. The package and the tariff with discount are as given below:
Country Package Amount Discount on the Package amount
China 90000per person 15%
Singapore 25000 per person 12%
Korea 80000 per person 20%
Japan 75000 per person 18%
Design a Class TourPromo using the descriptions given below:
Class name: TourPromo
Instance Variables/Data members:
String Cname: to store the country name
Nop: to store the number of persons travelling
Amt: to store the total package amount for the persons travelling
Famt: to store the final amount after the discount
Member Functions/Methods:
TourPromo() : default constructor
void getdetails(): to accept the country name and number of persons travelling
void calcAmt(): to calculate the total package amount and also the final amount based on
the above given criteria
void printvalue(): displays the country name, number of persons travelling , total package
amount and the amount to be paid after discount.
Write a main method, create object, call the above functions
Question 4 [15]
Define a class to accept a sentence from the user and perform the following:
i. Count and display the frequency of words that begins with a vowel
ii. Display only the uppercase letters and the digits present in the sentence
iii. Replace the blank spaces with the symbol ‘%’
iv. Print only the first and last word of the input sentence.
[Note: Write as a single program]

Question 5 [15]
Define a class to accept values in 4x4 array to store the characters. Perform the following:
i. Display the array elements in matrix form.
ii. Find the sum of the ASCII values of the array elements that are in upper case
iii. Find and display the frequency of digits in the array
iv. Form a new array by replacing uppercase characters with its equivalent lowercase
characters and vice versa. Display the newly formed array.
[Note: Write as a single program]

Question 6 [15]
Write a java program to input a number and print whether the number is a special number
or not. A number is said to be special if the sum of the factorial of the digits of the number
is the same as the original number.
Input: 145
Output:1! + 4! + 5! = 1+24+120= 145, so 145 is a special number.

Question 7 [15]
Write a java program to accept two arrays of size 10 from user, where array1 is of type
string and array2 is of type double. Write a method to combine these two arrays and print in
the following format. Assume necessary data and datatypes for it.
array1[]={“Aman”, “Saya”, “Jiya”,…..}
array2[]={78.0,87.0,89.45,…}
resultarray[]={“Aman:78.0”, “Saya:87.0”, “ Jiya:89.45”, …}
Question 8 [15]
Define a class to overload a method “pattern” as follows:
void pattern (): To print the following format using nested loop
7
76
765
7654
76543

void pattern (int n): To accept a 3-digit number and print square of its digits with original
digits and multiplication of all its digits.
Example: n=123
Output: 1: Square is:1
2: Square is:4
3: Square is: 9
Multiplication of digits: 6

You might also like