Computer Science, asked by PHOENIX234, 9 months ago

Computer sample question papers on 9th computer​

Answers

Answered by kushwahadeepak
3

Attempt all questions

Question 1.

(a) Define encapsulation. [2]

(b) Explain the purpose of using a ‘new’ keyword in a Java program. [2]

(c) What are literals? [2]

(d) Mention the types of access specifiers. [2]

(e) What is constructor overloading? [2]

Question 2.

(a) Differentiate between boxing and unboxing. [2]

(b) Rewrite the following condition without using logical operators:

if ( a>b || a>c )

System.out.println(a);

[2]

Rewrite the following loop using for loop:

while (true)

System.out.print("*");

[2]

(d) Write the prototype of a function search which takes two arguments a string

and a character and returns an integer value.

[2]

(e) Differentiate between = and == operators. [2]

Question 3.

(a) State the number of bytes and bits occupied by a character array of 10 elements. [2]

(b) Differentiate between Binary Search and Linear Search techniques. [2]

(c) What is the output of the following:

String a="Java is programming language \n developed by \t\'James Gosling\'";

System. out. println(a);

[2]

(d) Differentiate between break and System. exit(0). [2]

(e)

Write a statement in Java for √

(+)

3

|−|

[2]

(f) What is the value of m after evaluating the following expression:

m - = 9%++n + ++n/2; when int m=10,n=6

[2]

(g) Predict output of the following:

(i) Math.pow(25,0.5)+Math.ceil(4.2)

(ii) Math.round ( 14.7 ) + Math.floor ( 7.9)

[2]

(h) Give the output of the following java statements:

(i) "TRANSPARENT".toLowerCase();

(ii) "TRANSPARENT".compareTo("TRANSITION")

[2]

(i) Write a java statement for each to perform the following task:

(i) Find and display the position of the last space in a string str.

(ii) Extract the second character of the string str.

[2]

State the type of errors if any in the following statements:

(i) switch ( n > 2 )

(ii) System.out.println(100/0);

[2]

SECTION B (60 Marks)

Attempt any four questions from this Section.

The answers in this Section should consist of the Programs in either Blue J environment or any

program environment with Java as the 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 4.

Anshul transport company charges for the parcels of its customers as per the following

specifications given below:

Class name : Atransport

Member variables: String name – to store the name of the customer

int w – to store the weight of the parcel in Kg

int charge – to store the charge of the parcel

Member functions: void accept ( ) – to accept the name of the customer,

weight of the parcel from the user (using

Scanner class)

void calculate ( ) – to calculate the charge as per the weight

of the parcel as per the following

criteria.

Weight in Kg Charge per Kg

Upto 10 Kgs Rs.25 per Kg

Next 20 Kgs Rs.20 per Kg

Above 30 Kgs Rs.10 per Kg

surcharge of 5% is charged on the bill.

void print ( ) – to print the name of the customer, weight of the parcel, total bill

inclusive of surcharge in a tabular form in the following format :

Name Weight Bill amount

------- --------- ---------------

Define a class with the above-mentioned specifications, create the main method,

create an object and invoke the member methods.

Question 5.

Write a program to input name and percentage of 35 students of class X in two separate

one dimensional arrays. Arrange students details according to their percentage in the

descending order using selection sort method. Display name and percentage of first

ten toppers of the class.

[15]

Question 6.

Design a class to overload a function Sum( ) as follows:

(i) int Sum(int A, int B) – with two integer arguments (A and B) calculate and return

sum of all the even numbers in the range of A and B.

Sample input: A=4 and B=16

Sample output: sum = 4 + 6 + 8 + 10 + 12 + 14 + 16

(ii) double Sum( double N ) – with one double arguments(N) calculate and return

the product of the following series:

sum = 1.0 x 1.2 x 1.4 x …………. x N

(iii) int Sum(int N) - with one integer argument (N) calculate and return sum of only

odd digits of the number N.

Sample input : N=43961

Sample output : sum = 3 + 9 + 1 = 13

Write the main method to create an object and invoke the above methods.

Question 7.

Using the switch statement, write a menu driven program to perform following

operations:

(i) To Print the value of Z where Z =

3+0.5

where x ranges from – 10 to 10 with

an increment of 2 and Y remains constant at 5.5.

(ii) To print the Floyds triangle with N rows

Example: If N = 5, Output:

1

2 3

4 5 6

7 8 9 10

11 12 13 14 15

[15]

Question 8.

Write a program to input and store integer elements in a double dimensional array of

size 4×4 and find the sum of all the elements.

7 3 4 5

5 4 6 1

6 9 4 2

3 2 7 5

Sum of all the elements: 73

Question 9.

Write a program to input a string and convert it into uppercase and print the pair of

vowels and number of pair of vowels occurring in the string.

Example:

Input:

Similar questions