Computer
Computer
(i) The principle of OOP languages that highlights the essential features and hides the
background details is known as:
(a) Polymorphism (b) Encapsulation (c) Data abstraction (d) Inheritance
(ii) String is a:
(a) Class (b) Data type (c) Group of characters (d) All of these
(iii) Math.round (23.6) + Math.rint (28.5) = _______
(a) 52.0 (b) 53 (c) 52 (d) 53.0
(iv) The memory required to store the constant value 78L is:
(a) 2 bytes (b) 4 bytes (c) 8 bytes (d) 16 bytes
(v) The Scanner class is included in ________ package.
(a) java.lang (b) java.io (c) java.awt (d) java.util
(vi) A _______ method needs to be called with the help of an object.
(a) static (b) non-static (c) public (d) None of these
(vii) Which Character function is used to check if a letter is in upper case or not ?
(a) isUpperCase() (b) toUpperCase() (c) UpperCase() (d) touppercase()
(viii) Predict the output:
System.out.println ((int) Float.parseFloat("5.67")+0.33);
(a) 6.0 (b) 5.33 (c) 5.0 (d) 6.33
(ix) Division by 0 is an example of:
(a) Run-time error (b) Compile-time error (c) Logical error (d) All of these
Page 1 of 5
(x) The number of bytes occupied by an array of type char and size 5 is:
(a) 5 (b) 10 (c) 20 (d) 80
(xi) The return data type of a class method can be:
(a) int (b) void (c) String (d) All of these
(xii) Predict the value of r wherein r = 45 + "ZEBRA".charAt(2);
(a) 135 (b) 114 (c) 111 (d) 45A
(xiii) Given an array int p[ ] = {4, 6, 7, 2, 6, 5, 8}; The value of p[3] + p[5] is:
(a) 7 (b) 8 (c) 13 (d) 15
(xiv) Which of the following is not a token ?
(a) Literal (b) Identifier (c) Operator (d) Statement
(xv) Predict the output of the following expression:
"EFFECT".compareTo("AFFECT");
(a) 0 (b) 4 (c) -5 (d) false
(xvi) Default value of reference data type is:
(a) null (b) 0 (c) false (d) ""
(xvii) A loop can have ________ enclosed inside it.
(a) 1 loop (b) 2 loops (c) 3 loops (d) any number of loops
(xviii) The statement, System.out.print("Seven"+7+7); gives the output:
(a) Seven14 (b) Seven77 (c) 7Seven7 (d) 21
(xix) Which of the following is not an access specifier ?
(a) protected (b) public (c) private (d) return
(xx) for(int a=10;a>=1;a-=2)
{
for(int b=1;b<=5;b++)
{
System.out.print(a+b);
}
}
How many times the inner loop will get executed ?
(a) 5 (b) 10 (c) 25 (d) 50
Question 2
(i) Define Unboxing with an example. [2]
(ii) State two differences between Call by value and Call by reference. [2]
(iii) Evaluate: e- = --x + y++ * x-- + y; when e = 10, x = 1 and y = 0 (Show working). [2]
(iv) Write an equivalent Java expression for the following mathematical expression: [2]
| √𝑢2 + 2𝑎𝑠 |
(v) What is NullPointerException ? Give an example. [2]
Page 2 of 5
(vi) Rewrite the following code segment using ternary operator: [2]
if(p>1000)
d = p * 5/100.0;
else
d = p * 2/100.0;
(vii) Go through the following program and answer the questions given below: [2]
public class PreBoard2023
{
int x, y, z;
PreBoard2023 (int a, int b, int c)
{
x = a;
y = b;
z = c;
}
private void addMarks()
{
int total = x + y + z;
System.out.println("Total Marks = "+total);
}
}
(a) Name the member variables.
(b) Name the type of the constructor used.
(c) Name the variable declared within the method body.
(d) State the total number of method variables used.
(viii) Predict the data type and value of the variable res in the following statement: [2]
_______ res = "Knowledge".substring(0,4).concat("Mind");
(ix) Write a Java statement to replace 'E' with character 'A' in the word "INCIDENCE". [2]
(x) Go through the code given below and answer the following questions (Show working). [2]
int h = 0, i = 0;
while(h<=5)
{
h++;
if(h%2==0)
continue;
System.out.println(i);
i++;
}
(i) What will be the total number of executions of the loop ?
(ii) What will be the output ?
Page 3 of 5
Section B (60 Marks)
(Attempt 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 base.
Each program should be written using Variable descriptions / Mnemonic Codes so that the logic of the
program is clearly depicted.
Flow-charts and algorithms are not required.
Question 3
Design a class ‘Epidelco’ with the following specifications: [15]
Member methods:
Epidelco (double s, double c) : parameterized constructor to initialise the member
variables
void inputData() : to accept the amount of sale
void computeData() : to calculate the commission as per the following table -
Define a main() method to create an object of the above class and invoke the member
methods to get the desired result.
Page 4 of 5
Question 4
Define a class to overload a method display() for the purposes as follows: [15]
Question 5
Define a class to accept 10 integers (including positive and negative integers) in a single
dimensional array (SDA). Display all the negative numbers followed by the positive numbers
without changing the order of the numbers. [15]
Sample Input: 8, -7, 4, -3, 7, 23, -4, 98, -90, 33
Sample Output: -7, -3, -4, -90, 8, 4, 7, 23, 98, 33
Question 6
Write a program to declare an array for accepting a list of 30 integers. Sort the first 15
numbers in ascending order and the last 15 numbers in descending order by using the
mechanism of ‘Bubble Sort’. Finally print the original as well as the resultant array. [15]
Question 7
A ‘Palindrome word’ is a word that is identical to its reverse word and a ‘Special word’ is a
word that starts and ends with the same letter.
Define a class ‘PalinSpecial’ to accept a word and check whether the word is “Only
Palindrome”, or “Only Special”, or “Palindrome as well as Special” or “Neither Palindrome nor
Special”. [15]
Question 8
Write a program to declare an array country[ ] to accept and store the name of 10 countries
in alphabetical order and another array capital[ ] to accept and store their respective capital
cities. Now ask the user to enter the name of a country and search it using the technique of
‘Binary search’ in the first array. If it is found, display the name of the country along with its
capital city, otherwise display the message “COUNTRY NOT FOUND”. [15]
Page 5 of 5