ICSE Computer Application - Class X - 2014 PYQ
Table of Content:
- Question 1:
Which of the following are valid comments ?
- /*comment*/
- /*comment
- //comment
- */comment*/
- Question 2: What is meant by a package ? Name any two java Application Programming Interface packages.
- Question 3:
Name the primitive data type in Java that is:
- a 64-bit integer and is used when you need a range of values wider than those provided by int.
- a single 16-bit Unicode character whose default value is '\u0000'.
- Question 4: State one difference between the floating point literals float and double.
- Question 5: Find the errors in the given program segment and re-write the statements correctly to assign values to an integer array.
int a = new int (5); for (int i=0; i<=5; i++) a[i]=i; - Question 6:
Operators with higher precedence are evaluated before operators with relatively lower precedence. Arrange the operators given below in order of higher precedence to lower precedence:
- &&
- %
- >=
- ++
- Question 7:
Identify the statements listed below as assignment, increment, method invocation or object creation statements.
- System.out.println("Java");
- costPrice = 457.50;
- Car hybrid = new Car();
- petrolPrice++;
- Question 8: Give two differences between the switch statement and the if-else statement
- Question 9: What is an infinite loop? Write an infinite loop statement.
- Question 10: hat is constructor? When is it invoked?
- Question 11:
Rewrite the following program segment using if-else statements instead of the ternary operator:
String grade = (marks>=90)?"A": (marks>=80)? "B": "C";
- Question 12: Give the output of the following method:
public static void main (String [] args){ int a = 5; a++; System.out.println(a); a -= (a--) - (--a); System.out.println(a);} - Question 13:
List the variables from those given below that are composite data types:
- static int x;
- arr[i]=10;
- obj.display();
- boolean b;
- private char chr;
- String str;
- Question 14: State the output of the following program segment:
String str1 = "great"; String str2 = "minds"; System.out.println(str1.substring(0,2).concat(str2.substring(1))); System.out.println(("WH" + (str1.substring(2).toUpperCase()))); - Question 15:
What is the data type returned by the library functions :
- compareTo()
- equals()
- Question 16: State the value of characteristic and mantissa when the following code is executed:
String s = "4.3756"; int n = s.indexOf('.'); int characteristic=Integer.parseInt(s.substring(0,n)); int mantissa=Integer.valueOf(s.substring(n+1)); - Question 17: Study the method and answer the given questions.
public void sampleMethod() { for (int i=0; i < 3; i++) { for (int j = 0; j<2; j++) {int number = (int)(Math.random() * 10); System.out.println(number); }}} How many times does the loop execute?
What is the range of possible values stored in the variable number?
- Question 18: Consider the following class:
public class myClass { public static int x=3, y=4; public int a=2, b=3;} - Name the variables for which each object of the class will have its own distinct copy.
- Name the variables that are common to all objects of the class.
- Question 19: What will be the output when the following code segments are executed?
(i)
String s = "1001"; int x = Integer.valueOf(s); double y = Double.valueOf(s); System.out.println("x="+x); System.out.println("y="+y); (ii)
System.out.println("The king said \"Begin at the beginning!\" to me.");
Related Questions
- Assignment 1: Define a class named movieMagic with the following description:
- Assignment 2:
A special two-digit number is such that when the sum of its digits is added to the product of its digits, the result is equal to the original two-digit number.
Example: Consider the number 59.
Sum of digits = 5 + 9 = 14
Product of digits = 5 * 9 = 45
Sum of the sum of digits and product of digits = 14 + 45 = 59Write a program to accept a two-digit number. Add the sum of its digits to the product of its digits. If the value is equal to the number input, then display the message "Special two—digit number" otherwise, display the message "Not a special two-digit number".
- Assignment 3:
Write a program to assign a full path and file name as given below. Using library functions, extract and output the file path, file name and file extension separately as shown.
Input
C:\Users\admin\Pictures\flower.jpgOutput
Path: C:\Users\admin\Pictures\
File name: flower
Extension: jpg - Assignment 4:
Design a class to overload a function area( ) as follows:
- double area (double a, double b, double c) with three double arguments, returns the area of a scalene triangle using the formula:
area = √(s(s-a)(s-b)(s-c))
where s = (a+b+c) / 2 - double area (int a, int b, int height) with three integer arguments, returns the area of a trapezium using the formula:
area = (1/2)height(a + b) - double area (double diagonal1, double diagonal2) with two double arguments, returns the area of a rhombus using the formula:
area = 1/2(diagonal1 x diagonal2)
- double area (double a, double b, double c) with three double arguments, returns the area of a scalene triangle using the formula:
- Assignment 5:
Write a program to accept the year of graduation from school as an integer value from the user. Using the binary search technique on the sorted array of integers given below, output the message "Record exists" if the value input is located in the array. If not, output the message "Record does not exist".
Sample Input: - Assignment 6:
Using the switch statement, write a menu driven program to calculate the maturity amount of a Bank Deposit.
The user is given the following options:- Term Deposit
- Recurring Deposit
For option 1, accept principal (P), rate of interest(r) and time period in years(n). Calculate and output the maturity amount(A) receivable using the formula:
A = P[1 + r / 100]n
For option 2, accept Monthly Installment (P), rate of interest (r) and time period in months (n). Calculate and output the maturity amount (A) receivable using the formula:
A = P x n + P x (n(n+1) / 2) x r / 100 x 1 / 12
For an incorrect option, an appropriate error message should be displayed.