[go: up one dir, main page]

0% found this document useful (0 votes)
8 views10 pages

X - PreBoard 2023 Solved

The document is a preboard examination paper for Class X in Computer Applications, 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 has programming questions worth 15 marks each, from which students must answer four. The exam emphasizes Java programming concepts, including OOP principles, data types, and function overloading.

Uploaded by

tahaattar7868
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)
8 views10 pages

X - PreBoard 2023 Solved

The document is a preboard examination paper for Class X in Computer Applications, 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 has programming questions worth 15 marks each, from which students must answer four. The exam emphasizes Java programming concepts, including OOP principles, data types, and function overloading.

Uploaded by

tahaattar7868
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/ 10

SOLVED

PREBOARD EXAMINATION - 2023


CLASS X
COMPUTER APPLICATIONS

Time: 2 Hrs M.M.100


Answer to this paper must be written on the paper provided separately.
You will not be allowed to write during the first 15 minutes.
This time is to be spent in reading the question paper.
The time given at the head of this Paper is the time allowed for writing the answers.
This paper is divided into two Sections.
Attempt all questions from Section A and any four questions from Section B.
The intended marks for the questions or parts of questions are given in brackets[ ].

SECTION – A (40 Marks)


Attempt all questions

Question 1: [20]
Choose the correct answer and correct option.
(i) Data hiding results into :
(a) Abstraction
(b) Modularity
(c) Polymorphism
(d) Inheritance
(ii) Which OOP concept is implemented by function overloading :
(a) Encapsulation
(b) Abstraction
(c) Polymorphism
(d) Inheritance
(iii) Class String is present in which package ?
(a) java.util
(b) java.lang
(c) java.io
(d) java.awt
(iv) The size of data type long in bytes is :
(a) 2
(b) 4
(c) 8
(d) 16
(v) The return of Math function rint( ) is :
(a) int
(b) float
(c) double
(d) long
(vi) Which access specifier truly implements the concept of Encapsulation ?
(a) private
(b) public
(c) protected
(d) default
(vii) The ASCII code of alphabet D is :
(a) 98
(b) 100
(c) 68
(d) 69
(viii) The return type of string handling function equalsIgnoreCase( ) is :
(a) int
(b) char
(c) double
(d) boolean
(ix) Which of the following statement is Not True for the constructor function :
(a) It does not have any return type value
(b) It can be called by sub-class
(c) It is called at the time of object creation
(d) It initializes the data members of the class
(x) Conversion of primitive data type into its object is called :
(a) Autoboxing
(b) Unboxing
(xi) Base type of an array is :
(a) size of an array
(b) data type of array
(c) location of an element within array
(d) None of the above
(xii) A bundle of similar classes is called as
(a) Object
(b) Packed class
(c) Package
(d) Array
(xiii) A static method is also called as
(a) instance method
(b) class method
(c) abstract method
(d) defined method
(xiv) Type casting is :
(a) Implicit conversion
(b) Explicit conversion
(c) Type promotion
(d) Default conversion
(xv) A __________ method/variable is accessible only inside a particular package:
(a) private
(b) public
(c) protected
(d) default
(xvi) The parent class of a class is also called as :
(a) base class
(b) super class
(c) sub class
(d) both (a) and (b)
(xvii) If value of x = 15.25 and y = - 4.28 , select the output of the following expression:
Math. abs(Math.rint(x) +Math.floor(y))
(a) 11.0
(b) 10.0
(c) 12.0
(d) 9.0
(xviii) Which of the following in Not True about constructor function ?
(a) Constructor have the same name as that of the class
(b)` Constructors initializes the object
(c) Constructors can be more than one .
(d) Constructor can return only 1 value.
(xix) The Wrapper classes are available in package_____ :
(a) java.lang
(b) java.util
(c) java.io
(d) java.class
(xx) The objects can be passed as parameter to a user defined method by :
(a) call by value method
(b) call by reference method
(c) can not be passed
(d) both (a) and (b)
Question 2:
(i) Write the name of classes containing the following functions: [2]
a) parseInt( ) : class Integer b) nextLine( ): class Scanner
c) endsWith( ) : class String d) isLetter( ) : class Character

(ii) Write java expression for the following arithmetic expression : [2]
Y
| X + 2XY |
Math.abs( Math.pow(X,Y) + 2*X*Y)
(iii) Define Autoboxing and Unboxing. Give one example of each. [2]
Autoboxing : It refers to the conversion of a primitive data type into its respective
object. For example : int a = 10;
Integer obj = a;
Unboxing : It refers to the conversion of a wrapper class object into its respective
primitive data type . For example : Character ob = ‘A’;
char ch = ob;
(iv) Write a function prototype for a function check ( ) that takes one string and a
character as parameter and returns true or false. [2]
Answer : public boolean check( String str , char ch)

(v) Differentiate between a class variable and an instance variable . [2]


Class Variables | Instance Variables
1. These variables are declared by | 1. These variables are declared
using keyword static. | without using keyword static.
e.g. static int x; | e.g. int x;
2.These variables are shared by all | 2. Each instance/object of the class
the objects of the class. | has its own copy of these variables.

(vi) Differentiate between Autual parameters and formal parameters. [2]


Actual Parameters | Formal Parameters
1. These parameters appear in | 1. These parameters are declared in
function call statement. | function prototype.
2. These parameters stores the | 2. These parameters accepts values
actual values to be passed to the | from the actual parameters and
function. | function operates upon these
| parmeters.
(vii) Write output of the following given code (write working also). [2]
String str = “Computer Applications”;
System.out.println(str.length()+str.indexOf(‘t’));
System.out.println(str.substring(3,10)+str,substring(14));
Answer : Working: str.length( ) = 21, str.indexOf(‘t’) = 5
21 + 5 = 26
str.substring(3,10) = puter A
str.substring(14) = cations
output : 26
puter Acations
(viii) Write output for the given code : [2]
int arr[ ] = { 2,5,9,16,3,7,4,20, 6};
System.out.println(Math.sqrt(arr[3]));
System.out.println(Math.pow(arr[6],3);
Answer : working : arr[3] = 16, Math.sqrt(16) = 4
arr[6] = 4 Math.pow(4,3) = 64
output: 4.0
64.0
(ix) If the intial value of x= 6 and y = 4, write the output of the following expressions : [2]
(a) ++x + ++ x / x++ - ++ y % y
working : ++6 + ++7 / 8++ - ++4 % 5
= 7+8/8–5% 5= 7+1–0 = 8
(b) x++/++x – y++ + --y + x
working : 6++/++7 – 4++ + --5 + 8
= 6/8–4+4+8= 0–4+4+8 = 8
(x) Initialize an array of Strings that stores the names of all seven weekdays. [2]
Answer: String week[ ] = { “Monday”, ”Tuesday”, ”Wednesday”, ”Thursday”,
”Friday”, “Saturday”, “Sunday” };

SECTION B

(Answer any four questions from this Section.)


The answers to this Section should consist of the Programs in either Blue J 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]
Define a class Wages having following description:
Data members: String n : To store name
int h : To store total hours of working in a week
for which wages are to be paid
double rate : Rate of wages
double w : To calculate total wages
member functions:
input( ) : To input name and hours of working
calwage( ) : To calculate wages according to conditions
display( ) : To print all the details of employee and total wages
Write a program to compute wages as per the following conditions:
Number of hours Rate
Upto 40 hrs. Rs. 100 per hour

For next 10 hrs Rs. 150 per hour


For next 20 hrs Rs. 250 per hour
However, Working more than 70 hours per week is not allowed.
Write function main( ) also to create the object and call above mentioned functions.
Answer : import java.util.*;
class Wages
{ String n;
int h;
double rate, w; // variable declaration
public void input( )
{ Scanner sc = new Scanner (System.in);
System.out.println(“ Enter Name =”);
n = sc.nextLine();
System.out.println(“ Enter hours of working =”);
h sc.nextInt( );
} // end of fn input()
public void calwage( )
{ if (h <= 40 )
{ rate = 100;
w = h * rate; }
else if ( h <= 50)
{ rate = 150;
w = 40 * 100 + (h – 40)* rate;
}
else if ( h <=70)
{ rate = 250;
w = 40*100 + 10*150 + (h – 50) * rate;
}
else { System.out.println(“ Not allowed “); System.exit(0); }
} // end of fn calwage()
public void display( )
{ System.out.println(“ Name = “+ n);
System.out.println(“ Working hours = “+ h);
System.out.println(“ Rate per hour = “+ rate);
System.out.println(“ Total wages = “+ w);
} // end of fn display()
public static void main(String args[])
{ Wages obj = new Wages( );
obj.input( );
obj.calwage( );
obj.display( );
} // end of fn main()
} // end of class

VDT
NAME TYPE PURPOSE
n String To store name
h int To store working hours
rate double To store rate per hour
w double To calculate total wages

Question 4 [15]
Write a program to input any integer number and check if it is PrimePalindrome number or not.
A primepalindrome is a number which is prime as well as palindrome both.
For example : 131 which is both prime and palindrome .
Answer : import java.util.*;
class PrimePalindrome
{ public static void main(String args[])
{ Scanner sc = new Scanner(System.in);
int n, num, rev, flag,dig; // variable declaration
System.out.println(‘ Enter any integer number =”);
n = sc.nextInt(); // input
flag=0;
for (int i= 2 ; i < n; i++)
{ if (n % i ==0) flag =1;
}
rev=0;
num = n;
while (num >0)
{ dig = num %10;
num= num/10;
rev = rev *10 + dig;
}
if ( flag==0 && rev== n)
System.out.println(“ Number is PrimePalindrome”);
else
System.out.println(“ Number is not PrimePalindrome”);
} // end of fn main()
} // end of class
VDT
NAME TYPE PURPOSE
n int To store number
num int To store value of n for working
rev int Reversed number
dig int Chopped digit
flag Int Variable to check divisibilty

Question 5 [15]
Write a program to overload a function find( ) as follows:

● void find(String S1, String s2) : To compare the two strings if they are same alphabetically
or not and prints the message accordingly.
● void find(String str, char ch1, char ch2): To replace all the occurrences of character ch1 by
another character ch2 in the string str and to print the modified string.
Write function main( ) also to create the object of class and to call above mentioned functions.
Answer : import java.util.*;
class Overload
{ public void find (String S1, String S2)
{ if (S1.equals(S2))
System.out.println(“ Both Strings are same alphabetically”);
else System.out.println(“ Both Strings are not same alphabetically”);
} // end of fn

public void find(String str, char ch1, char ch2)


{ String newstr=””;
newstr = str.replace(ch1,ch2);
System.out.println(“ Modified String = ” + newstr);
} //end of fn

public static void main(String args[])


{ Overload obj = new Overload();
obj.find(“Computer”, “Computing”);
obj.find(“Hello”, ‘l’,’x’);
} // end of fn main()
} // end of class
VDT
NAME TYPE PURPOSE
S1 String To store first string
S2 String To store second string
str String To store string to be modified
ch1 char Old character to be relaced
ch2 char New character

Question 6 [15]
Define a class Numbers to store number of integers in an array in ascending order.
Now ask the user to input any particular number. Find if that number is present in the array
or not by using Binary Search Technique. Print the array and also the message if the number
is found or not.

Answer : import java.util.*;


class Numbers
{ public static void main(String args[])
{ Scanner sc = new Scanner(System.in);
int arr[ ] = { 4,7,9,15,18,25,32,40,45}; // Array creation
int n = arr.length;
System.out.println(“ Array = “);
for (int i = 0; i<n ; i++) // Printing of Array
{ System.out.println(arr[i]);
}
int val , f, l , m ,flag;
System.out.println(“ Enter value to search =”);
val = sc.nextInt(); // input
f =0; l = n-1;
flag =0;
while( f<= l)
{ m = (f + l)/2 ;
if ( val == arr[m])
{ flag =1; break; }
else if ( val > arr[m])
f = m+1;
else l = m-1;
}
if (flag ==1)
System.out.println(“ Value is present ”);
else
System.out.println(“ Value not present ”);
} // end of fn main()
} // end of class

VDT
NAME TYPE PURPOSE
arr[] int Array variable
n int Size of array
val int Value to be searched
f int First location
l int Last location
m int Middle location
flag int Variable used to check
i Int Loop control variable

Question 7 [15]
Write a program to accept a word and convert it to new word by replacing the vowels with the
letter just following it. Print the modified word.
For example: Input: computer
Output: cpmpvtfr

Answer : import java.util.*;


class Word
{ public static void main(String args[])
{ Scanner sc = new Scanner(System.in);
String str, newstr = “”; // Variable declaration
char ch;
System.out.println(“ enter any word =”);
str = sc.next(); // input
int len = str.length();
for (int i=0; i<len ; i++)
{ ch = str.charAt(i);
switch(ch)
{ case ‘A’ :
case ‘a’:
case ‘E’:
case ‘e’:
case ‘I’:
case ‘i’:
case ‘O’:
case ‘o’:
case ‘U’:
case ‘u’: ch++;
} // end of switch
newstr = newstr + ch;
} // end of loop
System.out.println(“ Modified string = “+ newstr);
} // end of fn main()
} // end of class

VDT
NAME TYPE PURPOSE
str String To store word
newstr String To modified word
ch char chopped character
i int Loop control variable
Question 8 [15]
Write a program to input a set of names in 1-D array of strings. Sort the name list in alphabetical
order using Bubble Sort technique. Print the sorted list of names.

Answer :
import java.util.*;
class Sort_Names
{ public static void main(String args[])
{ Scanner sc = new Scanner(System.in);
int n;
System.out.println(“ Enter total names =”);
n = sc.nextInt();
String names[] = new String[n]; // Array declaration
int i, j;
System.out.println(“ Enter names =”);
for (i=0 ; i<n ; i++)
{ names[i] = sc.next(); // Input of names
}
// Bubble Sorting
String temp;
for (i=0 ; i< n-1 ; i++)
{ for (j= 0; j<n-1- i ; j++)
{ if (names[j].compareTo(names[j+1]) >0)
{ temp = names[j];
names[j] = names[j+1];
names[j+1] = temp;
}
} // end of j loop
} // end of i loop
System.out.println(“ Sorted List of Names = “);
for (i=0; i< n; i++)
{ System.out.println(names[i];
}
} // end of fn main()
} //end of class

VDT
NAME TYPE PURPOSE
Names[] String Array to store names
n int Total number of names
i int Loop control variable
j int Loop control variable
temp String Temporary string to swap

You might also like