Professional Documents
Culture Documents
Computer Question Paper
Computer Question Paper
4) Which is the incorrect statement while defining the variable name? [1]
(a) It can begin with an alphabet using underscore () in between them.
(b) It must begin with a percentage sign (%).
(c) No spaces are allowed in variables.
(d) It cannot be a reserved word.
6) Define the term fall through condition with reference to switch () case.
[1]
7) What is the difference between charAt() and indexOf() function ?
[1]
8) What is an array?
[1]
Question 2.
(a) Using truth table, prove the p =>q is equivalent to ~q=>p. (2 x 4 = 8]
(b) Drawthe logic circuit diagram: A(B +C)
(c) Define tautologies and
(d) Define Truth Table.
contradictions.
Question 5.
Define a class MatRevto reverse each element of a matrix.
(8)
For example:
72 371 5 27 173 5
12 6 426 21 6 624
5 123 94 5 321 49
Some of the members of the class are given below:
class name MatRev
Data members/Instance variables
ar) :to store integer elements
m :to store number of rows
n :to store number of columns
Member Method/Member Functions
matrev(int mm, int nn) : parameterised constructor to initialise the data members m=mm and n=nn
int reverse(int x) : returns the reverse of the number x
void assign() : to assignthe reverse number in the new array
void show( ) : displays the matrix.
Define the class MatRev giving the details of the construcotr( ), int reverse(int) and show(). Define the main ()
function to create an object and call the functions accordingly to enable the task.
Question 6. [8]
Define aclass Encrypt to replace only the vowels in a word by next corresponding vowel and forms a
new word. Example: Input : COMPUTER
Output: CUMPATIR
Class name :Encrypt
Data member/instance variables:
wrd : to store a word
len : integer to store the length of the word
newwrd : to store the crypted word
Member functions/methods:
Encrypt () default constructor to initialize data members with legal initial values.
void acceptword() to accept aword in UPPER CASE.
finds the frequency of the vowels and consonants in the word stored in 'wrd' and
void freqvowcon()
displays
them with an appropriate message.
void nextvowel() :replaces only the vowels from the word stored in 'wrd' by the next corresponding
Vowel
from the word stored in 'wrd' by the next corresponding vowel and assigns it to
'newwrd',
withthe remaining alphabets unchanged.
void disp() : display the original word along with the encrypted word.
Specify the class encrypt giving details of the constructor(), void acceptword), void freqvowcont(), void
nextvowel() and void disp(). Define main() function to create an object and callthe functions accordingly to
enable the task.
Question 7. [8]
Define the class BinSearch having the following description:
Class name BinSearch
Data Members:
arrl] : tostore integer elements.
n
: integer tostore the size of the array
Member Methods:
BinSearch() :parameterized constructor to initialize array and another variable with default value;
void fillarray() : toenter elements in the array in ascending order, enter a number vfor searching
Int bin_search(int I, int u, int v) : searches for the value v using binary search technique and returns its
location if found otherwise return -1.
Void display( ):to display the appropriate message .
Define the class BinSearch giving details of the constructor (0, void fillarray () and int bin _search (int, int, int).
define the main() function to create object andcall the functions accordingly toenable the task.