Computer Practice
Computer Practice
COMPUTER APPLICATIONS
SECTION A
(Attempt all questions from this Section.)
Question 1 (1 × 20 = 20)
Choose the correct answers to the questions from the given options.
(Do not copy the question, write the correct answers only.)
(i)
1
(iii) The result of dividing by zero in java is
(a) Error
(b) Exception
(c) Infinite
(d) None
(iv) When a composite data type is converted to a corresponding primitive data type,
is called:
(a) Boxing
(b) Unboxing
(a) 20 bytes
(b) 40 bytes
(c) 80 bytes
(a) 10
(b) 9
(c) 11
2
(viii) The output of Math.round(8.5) + Math.floor(-4.3) is:
(a) 14.0
(b) 4.0
(c) 14
(d) 4
(ix) Implicit type conversion is also known as
(a) coercion
(a) X[n]
(b) X[n+1]
(c) X[n-1]
(d) X[2n]
(xi) Which of the following functions is used to check whether a given character is a
tab
(a) isTab()
(b) isTabSpace()
(c) isSpace()
(d) isWhitespace()
(xii) Cell numbers of a dimensional array are known as …..
(a) packets
(b) blocks
(c) subscripts
(d) compartments
3
(xiii) Name the package that contains wrapper classes:
(a) java.lang
(b) java.util
(d) java.awt
(xiv) The technique in which the change in the formal parameter is reflected in the
actual parameter is known as …..
(a) call by value
(b) indexOf()
(c) endsWith()
(d) none
(xvi) In the following program code, what is the process involved?
int x=12;
Integer y = x;
(a) boxing
(c) packaging
(d) unboxing
(xvii) Assertion(A): The indexOf() method is used for searching for the first
occurrence of a character in a string.
Reason(R): The indexOf() and lastIndexOf() methods do the same
function.
(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
4
(xviii) Read the following text, and choose the correct answer:
(c) class
(d) variable
Question 2
5
Fix the code so that it compiles and runs correctly.
boolean dh = True; boolean cr= true; if (dh && cr)
System.out.println("You cannot go out"); else
System.out.println("You can go out");
(iv) Sam executes the following program segment and the answer displayed is zero [2]
irrespective of any non zero values are given. Name the error. How the program
can be modified to get the correct answer?
void triangle(double b, double h)
{ double a; a = ½ * b * h;
System.out.println(“Area=”+a); }
(v) How many times will the following loop execute? What value will be returned? [2]
int x=2;
int y=50; do{
++x;
y-=x++;
}
while(x<=10); return y;
(vi) Write the output of the following String methods: [2]
(a) "ARTIFICIAL ".indexOf('I' )
(b) “DOG and PUPPY”. trim().length()
(vii) Name any two jump statements. [2]
(viii) Predict the output of the following code snippet: String a="20"; [2]
String b="23";
int p=Integer.parseInt(a); int q=Integer.parseInt(b); System.out.print(a+"*"+b);
(ix) When there is no explicit initialization, what are the default values set for [2]
variables in the following cases?
(a) Integer variable
(b) String variable
x = Math.pow(n[3] , n[2]);
y = Math.sqrt(n[5] + n[0])
6
SECTION B(4×15=60)
Discount (in
Cost
percentage)
void display() – To display customer name, mobile number, amount to be paid after discount
Write a main method to create an object of the class and call the above member methods.
7
Question 4
Write a program to input a number and print whether the number is a special number or not.
(A number is. said to be a special number, if the sum of the factorial of the digits of the number is
same as the original number).
Example: 145 is a special number, because 1!+4!+5! = 1 + 24 + 120 = 145 (Where! stands for
factorial of the number and the factorial value of a number is the product of all integers from 1 to
that number, example 5! = 1*2*3*4*5 = 120).
Question 5
Write a Java program to initialize a square matrix of order 4×4 to store integers. Display the
matrix data in the format of matrix. Also check whether the given matrix is a UNIQUE matrix of
not.
A UNIQUE matrix is a matrix whose sum of left diagonal elements is equal to the sum of right
disgonal elements.
Question 6
Write a program to input twenty names in an array. Arrange these names in ascending order of
letters, using the bubble sort technique.
Sample Input:
Rohit, Devesh, Indrani, Shivangi, Himanshu, Rishi, Piyush, Deepak, Abhishek, Kunal, .....
Sample Output:
Abhishek, Deepak, Devesh, Himanshu, Indrani, Kunal, Piyush, Rishi, Rohit, Shivangi, .....
Question 7
(ii) void find(String si) – to find and display only vowels from string si, after converting it to lower
case.
Example:
Input:
s1 = “computer”
Output:
oue
Question 8
Write a program to initialize the Seven Wonders of the World along with their locations in two
different arrays. Search for a name of the country input by the user. If found, display the name of
8
the country along with its Wonder, otherwise display “Sorry Not Found!”.
Seven wonders — CHICHEN ITZA, CHRIST THE REDEEMER, TAJMAHAL, GREAT WALL
OF CHINA, MACHU PICCHU, PETRA, COLOSSEUM
Locations — MEXICO, BRAZIL, INDIA, CHINA, PERU, JORDAN, ITALY
Example — Country Name: INDIA Output: INDIA-TAJMAHAL
Country Name: USA Output: Sorry Not Found!