10 th computer science application questions
10 th computer science application questions
Question 1.
Choose the correct option and write the correct answer: [20]
(i) What does the object has?
(a) Attributes
(b) State
(c) Behavior
(d) All of these
(vii) If a user wants to execute a loop 10 times, which of the following statements will be used
(a) for (i=6; i<=26; i=i+2)
(b) for (i=3; i<=30; i=i+3)
(c) for (i=0; i<10; i++)
(d) All of the above
(xii) Which of the following loop checks condition first and then the execution begins?
(a) do-while
(b) do
(c) while loop
(d) for
(xiv) Name the operator that is used to allocate memory space for an object.
(a) Dot
(b) new
(c) Both a and b
(d) None of these
(xv) Which is false about constructor?
(a) Constructors cannot be synchronized in java
(b) Java does not provide default constructor
(c) Constructors can have a return type
(d) “this” and “super” can be used in constructor
Question 2.
(a) Write two diffrences between ‘break’ and ‘continue’ keyword. [2]
(b) Write two differences between pure function and impure function. [2]
(c) Write two diffrences between constructor and method [2]
(d) What will be the output of the following code? [2]
String s="Today is Test";
System.out.println(s.indexOf('T'));
System.out.println(s.substring(0,7) + " " +"Holiday");
(e) Explain ‘Fall through’ with reference to a switch case statement. [2]
(f) Give the output of the following string functions: [2]
"MISSISSIPPI”. indexOf('S') + "MISSISSIPPI”. LastIndexOf('I')
"CABLE".compareTo("CADET")
(g) Analyze the given program segment and answer the following questions: [2]
i. Write the output of the program segment.
ii.How many times does the body of the loop gets executed?
for (int m = 5; m <= 20; m += 5)
{
if (m % 3 == 0)
break;
else
if (m % 5 == 0)
System.out.println(m);
continue;
}
(h) Give the output of the following program segment and also mention how many times the loop is executed:
int i;
for (i = 5; i > 10; i ++)
System.out.println( i );
System.out.println(i * 4); [2]
Question 3.
Design a class name ShowRoom with the following description:
Instance variables / Data members:
String name — To store the name of the customer
long mobno — To store the mobile number of the customer
double cost — To store the cost of the items purchased
double dis — To store the discount amount
double amount — To store the amount to be paid after discount
Member methods:
ShowRoom() — default constructor to initialize data members
void input() — To input customer name, mobile number, cost
void calculate() — To calculate discount on the cost of purchased items, based on following criteria
Question 4.
Write a program to input a sentence and convert it into uppercase and count and display the total number
of words starting with a letter 'A'.
Example:
Sample Input: ADVANCEMENT AND APPLICATION OF INFORMATION TECHNOLOGY ARE
EVER CHANGING.
Sample Output: Total number of words starting with letter 'A' = 4 [15]
Question 5.
Write a program to accept 10 integers and perform binary search for an element input by user.
[15]
Question 6.
Write a program in Java to enter a number containing three digits or more. Arrange the digits of the
entered number in ascending order and display the result.
Sample Input: Enter a number 4972
Sample Output: 2, 4, 7, 9 [15]
Question 7.
Design a class to overload a function check() as follows:
void check (String str, char ch) — to find and print the frequency of a character in a string.
Example:
Input:
str = "success"
ch = 's'
Output:
number of s present is = 3
void check (String s1) — to display only vowels from string s1, after converting it to lower case.
Example:
Input:
s1 ="computer"
Output: o u e [15]
Question 8.
Write a program to accept a list of 20 integers. Sort the first 10 numbers in ascending order and the next
10 numbers in descending order by using bubble sort. Finally print the complete list. [15]
************************************************************************************