0% found this document useful (0 votes)
244 views7 pages

Practise Model Papers

OOPs concepts include classes and objects. A class defines attributes and behaviors, and objects are instances of classes. Abstraction hides unnecessary details, and encapsulation binds together code and data. Class defines the general properties, and objects are specific instances of classes. Keywords cannot be used as identifiers, and Java is case sensitive. Operators are used to perform operations, and throw throws exceptions while throws declares exceptions. Instance variables and methods are associated with objects. Logical operators like && and || are used to combine conditions. Debugging is the process of finding and resolving defects. The main method is the entry point of a Java program. Local variables are declared within a method and global variables are declared outside.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
244 views7 pages

Practise Model Papers

OOPs concepts include classes and objects. A class defines attributes and behaviors, and objects are instances of classes. Abstraction hides unnecessary details, and encapsulation binds together code and data. Class defines the general properties, and objects are specific instances of classes. Keywords cannot be used as identifiers, and Java is case sensitive. Operators are used to perform operations, and throw throws exceptions while throws declares exceptions. Instance variables and methods are associated with objects. Logical operators like && and || are used to combine conditions. Debugging is the process of finding and resolving defects. The main method is the entry point of a Java program. Local variables are declared within a method and global variables are declared outside.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 7

Computer Applications

Q. 1.
i. What is OOP’s and define its basic concept.
ii. What is a class and how it is declared?
iii. What do you mean by Abstraction and Encapsulation?
iv. Write the difference between Class and Object.
v. What is class? How are objects related to the class?
Q. 2.
i. What are the keywords? Can keyword used as identifier.
ii. Is Java case sensitive? What is the mean by case sensitive?
iii. What is the function of operator?
iv. What is the difference between throw and throws?
v. What are instance variable and instance methods
Q. 3.
i. Write a statement that uses a conditional operator to set grant to 10 if speed is more than 68 and to 0 otherwise
ii. How many times are the loop execute?
a. x = 5; y = 50;
while (x<=y)
{
x=y/x;
}
b. ints = 0; i = 0;
while (i++<5)
s+=i;
Q. 4. Give the output of the following statements
i. Math.ceil(-28.25)
ii. Math.rint(38.96)
iii. Math.floor ( 144.99)
iv. Math.abs ( 3489.45)
v. Math.max ( Math.min (15, 25), 5)
vi. ( int ) (“scholar”.charAt(2))
vii. “TuTOrIAl”.indexOf(‘l’)
viii. “MISSISSIPPI”.lastindexOf(‘S’)
ix. “kumarvivek”.substring( 3, 4)
x. Math.sqrt(100);
Q.5.
a. A member function having the same name as that of its class is called _____ function.
b. An _____ is a combination of token i.e., of literals ,operators , variables and parenthesis used to calculate a value.
c. JVM combined with _____ makes Java platform.
d. The Java statement available to jump from one loop to another is _____.
e. _____ means that if the two operand bits are different , the result is 1.
Q. 6. Differentiate between: switch and if-else
a. class and object
b. equals( ) and equalsIgnoreCase( )
c. parameterized and non-parameterized constructor
Q. 7. Write short notes with example:
a. Nested Loop
b. Wrapper class
c. Function overloading
d. Ternary Operator
e. this keyword
f. Package
g. compareTo( )
Q.8. What are escape sequences? List any two sequences with their functions.

Q.9 (a) Find which one is not a character literal.


a. ‘1’
b. ‘10’
c. '\0’
d. ‘\n’
(b) Which of the following return type does a constructor have:
a. Void
b. Boolean
c. Int
d. None
(c) The arguments of the function given in the function definition are called:
a. Formal parameter
b. Actual parameter
c. Reference parameter
d. None
(d) The address of a memory location which can store a value and which may change during the program execution is
known as:
a. Identifier
b. Keyword
c. Separator
d. Literal
Q. 10. Fill in the blanks:
a. The compiler ignores the characters in the _____.
b. _____ is used to force a conversion from one data type to another.
c. The logical _____ is equivalent to OR function.
d. A _____ is a blue print of the attributes and the methods common to all its objects.
e. When an expression within the parenthesis in a set of statements returns zero value, the condition is considered to
be _____.
Q. 11. State True/False:
a. Switch statement can use characters and numbers in its case.
b. The continue statement force an early iteration of a loop.
c. do …. While is an entry controlled loop.
d. For every primitive type in java , there is a built in object type called Wrapper class.
e. Software objects interact and communicate with each other using machine language.
Q. 12. Write the output:
(a) b)
public class test public class result
{ {
public void main( ) public static void main( )
{ {
int a=5,b; char a= 'a' ;
b=2*a - - + - - a; System.out.println(+a);
System.out.print(+a+" "+b); a++;
System.out.println(a);
} }
} }
Q. 13. Explain the following with example.
a. Type casting
b. Switch statement
c. Literal
d. Looping
e. Possible loss of precision
Q. 14. Multiple choices:
(i) The smallest element of a program that is meaningful to the compiler:
a. keyword
b. class
c. token
d. object
(ii) When an expression contains more than one operator then their execution is based on their:
a. precedence
b. type
c. method
d. none
(iii) The string class provides function to convert other objects to string objects:
a. toString ( )
b. java.io
c. comments
d. all
(iv) The variable which is declared inside a class is:
a. local variable
b. instance variable
c. both
d. none
(v) Find the odd one out :
a. int prime ( )
b. double radius ( )
c. String reverse ( )
d. void display ( )
(vi) Comments can be written
a. In the beginning of the prog.
b. at the end of the prog.
c. anywhere
d. none
Q.15. Fill in the blanks:
a. A program having _____ error does not compile.
b. An _____ is a combination of constants, operators, variables which are used to calculate some value.
c. If n = 5 and m = 9, then System.out.println( n > m ); will return _____ .
d. Condition in _____ loop is tested after execution.
e. _____ function removes white spaces from both the ends of a string.
f. _____ function returns the all the characters from a given location to the end of the string.
Q.16 Write the output
(i) public class test_1 ii) public class test_2
{ {
public void res_1( ) public void res_2( )
{ {
int m,p=2; int k=1,j=0
for( m=0;m<=p;) while ( k <=10)
{ {

System.out.println( m ); for(j=k; k<5;j++)


} {
} System.out.print(j+“ ”);
} }
System.out.println( ); k++ ;
k ++;
}}

iii) public class test_3 iv) public class test_4


{ {
int a=5,b=0; int x,y=2
public void res_3( ) public void res_4( )
{ {
while(b<5) for(x = y; x<=50;)
{ {
b++; a- - ; System.out.print(x+ “ ”);
System.out.println(a+” “ +b); x*=5;
} }
System.out.println(a+” “ +b); System.out.print(x);
} }
} }
Q. 17. Answer the following:
a. What is the use of Logical operator and (&&) and or ( || ) ?
b. What do you mean by Debugging?
c. Explain Dynamic initialization
d. Explain abstraction?
e. Explain the function of return type in a function.
Q. 18. Differentiate between:
a. compareTo( ) and equalsIgnoreCase ( )
b. Math.ceil ( ) and Math.floor ( )
c. constructor( ) and method ( )
d. class and object
e. compiler and interpreter

Q.19.
a. What is significance of abstraction in class. Explain with example.
b. What is main method ? What is its role in java program?
c. What is Local and global variables in Java?.
Q.20.
a. Differentiate between Operator and expression.
b. Define bytecode
c. Evaluate Math.ceil(7.8)+Math.round(6.3);
Q.21.
a. What is BufferedReader.
b. Write a syntax of nested if-else.
c. Explain the concept of wrapper class in Java.
d. What is difference between binary search and Linear search.
Q.22.
a. Distinguish break and continue statements with example.
b. What is prototype of a method ? Explain.
c. Explain exception class.
d. Define constructor and ‘static’ keyword.

Q. 23.
(a) Name the four integer data types of Java.
(b) What is a “ternary operator” of Java?
(c) What is meant by “nesting of loops”? Give suitable example.
(d) Differentiate between int and float data type. Give one example for each.
(e) What is Polymorphism? Give one example.
Q. 24.
(a) What is meant by “exit controlled loop”? Give one example.
(b) Differentiate between constructor and finalizer with suitable examples for each.
(c) What do you understand by the term “Escape Sequence”? Give two examples with proper explanation.
(d) Differentiate between data abstraction and data encapsulation.
Q.25. (a) Give the output of the following code snippets:
(i) int f = 1, i = 2;
do {

f * = i;
i++;
}while ( i < 5 );
System.out.println ( f );
(ii) int a = 0, p;
for( int i = 0; i < 5; ++i ) {
a = a + p * i;
System.out.println( a );
}
(b) Find error(s), if any in the following code snippets:
(i) int i [][] = {{1, 2}, {3, 4}};
i [1, 1] = 5;

(ii) int b[] = new int [10];


for ( int i = 0; I <= b.length; ++i )
b[i] = 1;
Q.26. (a) Write the equivalent do-while loop for the following for loop:
for ( ; ; )
{s; } //s represents any statement
(b) Assume that i = 1, j = 2, k = 3, and m = 2. What does act of the following statements print?
i. System.out.println ( k + m < j | 3 – j >= k );
ii. System.out.println ( ! ( k > m ));
(c) What would happen when the following is compiled and executed? [3 + 3 = 6]
(i) class Example {
int x, y;
String name;
public static void main ( string[] args) {
Example ex = new Example ();
System.out.println ( “ex is ’’ + ex.name + “ ” + ex.x + “ ’’ + ex.y);
}
}
(ii) public class XYZ{
public static void main(String[ ]args) {
for ( int i = 0; i < 2; ++i ) {
for ( int j = 2; j >= 0; j-- ) {
if ( i = = j )
break;
System.out.println ( “i = ” + i + “j = ” + j );
}
}
}
}
Section – B

Q. 1. Write a class with a special member function to input a multi digit number ( max. 9 digit) and print the following:
1. total number of even and odd digits
2. the reverse number
3. total number of zero’s present.
Q.2. Write a class to generate the following series using a special member function.
1
2 3
4 5 6
7 8 9 10
Q.3. Digital World announces seasonal discount on the laptops in the given order.
Cost of the laptop Discount
Rs.20,000 - Rs.30,000 10%
Rs.30,000 – Rs.40,000 15%
Rs.40,000 – Rs.50,000 18%
> = Rs.50,000 20%
An additional discount of 5% on all types of laptops is given. Sales tax is calculated at 12% on the price after the
discounts. Define a class to accept the cost of the laptop and print the amount payable by the customer on purchase
( use constructor).
Q.4. Write a class to enter a proverbial statement and display the frequency of each alphabet present in it.
Q.5. Write a class to accept a multi digit no.(max. 8 digits) and do the following:
a. print the reverse number.
b. print the absolute difference between them.
c. print smallest digit.
Q.6. Write a program to display hcf and lcm of any two nos.
Q.7. Write a program to accept a sentence from the user and print out the frequency of each letter.
Q.8. The length() method of string class returns the number of characters in a given string. However , here you have to
develop a method OnlyChars() that should return the count of characters excluding the spaces in a string.
Q. 9. Write a method namely Revwords() of class strings that should receive a string and return the strings with its words
reversed individually e.g. if you pass “ I love Java”, it should return “ I evol avaJ”
Q. 10. Write a method in java to calculate thr value of the following series :
S = (1 +2 )/(1 * 2) + (1 +2 + 3)/(1 * 2 * 3) +.........+ (1 +2 +3 +4 +...........+n)/(1*2*3*............*n)
Q. 11. Write a program to input a string and display the string with the first character of every word in capital and the rest of the
word in small letters.
Q. 12. write a method to find out the total number of prime and palindrome numbers from a range of numbers.
Q. 13. write a program in java to read a number having more than 5 digits and print whether the given number is divisible by
11 or not. A number is divisible by 11 if and only if the difference of the sums of digits at odd positions and even
positions is either zero or divisible by 11
Q. 14. Write a program to initialize the given data (2,5,4,1,3) in an array and find out the minimum and maximum values along
with the sum of the given elements.
Q. 15. Write a program to input twenty names in an array and display all the names whose first alphabet matches with the
alphabet entered by the user.
Q. 16. Write a program using string function to input any string and print the same in alphabetical order.
Q. 17. Write a program to enter a sentence and display the following.
a. Number of upper case vowels
b. Number of lower case vowels
c. Number of digits
d. Number of consonants
e. Number of blank spaces
f. Number of special character
Q.18. Input the index number and name of boys appearing in the coming ICSE Examination and print the list with index
numbers in a sequence. Also make sure while entering the index numbers that no index should be repeated.

Q. 19. Define a class named sentence with a data member named s, string type and the following methods:
 Sentence(string)-to assign an initial value to s
 Countword()-to count and return the number of words in the sentence
 Palindrome()-to test whether the sentence is a palindrome and return true or false.
Q.20.
(a) Write a program to print following pattern.
1
01
101
0 1 0 1….. n
(b) Write a program to enter a string and print the first character of that string at last.
For eg. “deep” ->eepd
“b”-> b
“dv”->vd
Q.21.The single dimensional arrays A and B are sorted in ascending order. Create an array C to combine them into a
descending order.
Q.22.
a. Write a class to enter three numbers in a function numb( ). And print the numbers entered if it is possible that the
addition of any two numbers give third number.
For eg. numb(3,4,7) -> here 3+4=7
numb(8,5,3) -> 5+3=8
numb(8,10,2) -> 8+2=10
b. Enter two arrays of characters named Arr1 & Arr2, in alphabetical order. Print the count of the number of characters
which appear in both arrays.
Arr1 {"a", "c", "x"}
Arr2 {"b", "c", "d", "x"}) → Prints 2

Q.23. Wtite a program in Java to input a sentence and find out how many letters are starting with vowels.
Q.24. Write a program in java to input a sentence and find out how many palindromes are there in the sentence.
Q.25. Write a program in java to input a sentence and find out total number of blank spaces and words.
Q.26. Write a program in java to input a sentence and find out the smallest word along with its position.
Q.27. Write a program in java to input a sentence and convert all uppercase letters to lowercase and vice versa.
Q.28. Write a program in java to input a sentence and find out the sum of the ASCII values of the characters.
Q.29. Write a program in java to input a sentence and reverse each word of the sentence.
Ex, I like School.
I ekil loohcS
School like I.
Q.30. Write a program in java to input a sentence replace all vowels with “*” and all consonants with “@”.
Q.31. Write a program in java to input a sentence display how many times a particular character appear in a string.
Q.32. Write a program in java to input a word and check whether it is Pig Latin or not.
Q.33. Write a program in java to input a sentence and delete a particular word .
Q.34. Write a program in java to input a sentence and add a particular word as specified by the user.
Q.35. WAP to accept a word. Pass it to the function magic(String x). The function checks the string for the presence of
consecutive letters. If two letters are consecutive in any position the function prints it is a magic string otherwise it
prints not a magic string.
Q.36. WAP to accept a sentence. Print all the words that start with a vowel and end with a consonant. For example:
Input :“the purpose of education is to replace an empty mind with an open one”
Output : of
education
is
an
empty
an
open
Q.37. Design a class with 3 overloaded functions according to the following specifications:
i. to find and print the largest out of the two integers
ii. to find and print the largest out of the three integers
iii. to find and print the largest out of the three real numbers
Q.38. WAP amicable(int,int) with a default constructor, a parameterized constructor and the following two functions :
a. checkAmicable(int,int) – this function returns true if the two arguments are amicable otherwise it returns false.
b. main(int,int) – this function invokes the above function and prints whether the parameters passed to it are amicable or
not.
Hint : a pair of numbers are amicable if the sum of the factors of one number (excluding itself) is equal to the second
number and vice-versa.
Q.39. Design a menu driven program, that accepts an integer and displays the following menu :
MENU
i. displays the sum of the digits of the numbers
ii. displays whether the number is a palindrome or not
iii. displays whether the number is a special number or not
iv. exit
Q.40. Design a class to accept name, class roll number and marks in phy, chem, bio and comp. of students until zero is
entered as the roll number. Calculate and print the following :
i. names of students who score less than 40 in any of the given subject.
ii. All over average of the student
iii. Name and roll number of the student with the highest average
Q.41. Design a class to accept the values of a,b,c and n. Calculate and print x and y, where :
x= (abc)2 / !1 + (abc)4 / !2 +……….(abc)n*2 / !n
y=2+(2*4)+(2*4*6)+………..(2*4*………n)
Q.42. Create a class Rectangle that has attributes length & width each of which defaults to 1. It has methods that calculate the
perimeter and the area of the rectangle. It has set and get methods for both length and width. The set and get methods
should verify that length and width are each floating-point numbers larger than 0.0 and smaller than 20.0.
Q.43. Create and populate one-dimensional integer array where duplicacy of elements is allowed. Using any searching
algorithm you like, locate the search key (i.e. the element to be searched) a well as its number of occurrence in the
array taking the search key as an input from the user.
Q.44. Write an application that has a method integerPower (base, exponent) that returns the value of base exponent.
For example, integerPower (3, 4) calculates 34 (or 3 * 3 * 3 * 3). Assume that exponent is a positive, nonzero integer
and that base is an integer. The method should use a for or while loop to control the calculation. Do not use any Math-
library methods.
Q .45. The single dimensional arrays A and B are sorted in ascending order. Create an array C to combine them into a
descending order.(10)
Q.46. Primorial(p#) is defined to be a product of prime numbers less than or equal to p.
For eg. 3# =2*3=6 5# =2*3*5=30 Design a class primo_numb with two methods
1. to check whether entered number is prime number or not
2. to print the primorial of that number.
Q.47. Write a prog to input a string and two words and replace first word with second word as in sample example:

Input: hot plate with hot egg


Word 1: hot
Word2: cold
Output: cold plate with cold egg
Q.48. WAP to input a name and print its initials as
Input Subhas Chandra Bose
Output:
(i) S.C.Bose
(ii) Bose, S.C.
(iii) S.C.B.
Q.49. Write a program in java to input a sentence and find out how many palindromes are there in the sentence also print the
palindromes.
Q.50. Write a function to suppress negative elements of an array to bottom without altering the original sequence i.e. if array
contains 5 , -4 , 3 , -2 , 6 , -11 , 12 , -8 , 9 Then the return array will be : 5 , 3 , 6, 12 , 9 , -4 , -2 , -11 , -8
Q.51. Write a program to input a sentence. Create a function convert(int n), where n is an integer value in positive or negative.
This function is used to encode or decode the given string by shifting each character of a string the number of times as
specified by user.
Ex.- Input- Good Boy
Shift value –3
Output – Jrrg Erb
Q.52. A company sells 15 items at different rates and details of sells (total amount) of each item are stored month wise from
January to December. Write a class sale to compute and display the following.
a. The annual sale of each item
b. The total sale of all items for each month
Q.53. In an interview 20 candidates are selected to continue their job as P.R.O. There names , date of birth and monthly salary
are stored randomly in different single dimension arrays respectively. Write a program to arrange and display those
names in alphabetical order along with other details using sequential sorting method.
Q. 54. A number is said as a perfect number if the sum of its factors is double of the number. By knowing this logic write a
program to calculate and display all the three digit perfect numbers and total number of such numbers are generated.

You might also like