SUB: COMPUTER                       FOR CLASS X

  This paper is divided into two sections. You are to answer all the questions from Part I, and any four from Part II.

SECTION A (40 Marks)

Attempt all questions from this Section

Question 1.

  1. What is the difference between abstraction and polymorphism? [2]
  2. What is the difference between unary and binary operator? [2]
  3. Explain function overloading with an example. [2]
  4. What will be the output of the following code? [2]

int m=5;

int n=13;

for(int i=1;i<=15;i++);

m++;

–n;

System.out.println(“m=”+m);

System.out.println(“n=”+n);

  1. What is keyword? Give two example.                                                             [2]

 

Question 2.                                                                                                                    [5*2=10]

  1. Define the term bytecode.
  2. What do you mean by type conversion? How is implicit conversion different from

Explicit conversion?

  1. What do you understand by JVM?
  2. What do you understand by primitive and non-primitive data type?
  3. Convert the following segment into equivalent for loop             public void display()

{

int i=10;

while ( i !=0)

{

System.out.print(i +” “);

i–  ;

}

}

Question 3.                                                                                                               [5*2=10]

  1. Give two differences between switch statement and if-else statement.
  2. What is an infinite loop? Write an infinite loop statement.
  3. If the value of a = 3, what does the expression below evaluate to,

a + = a + + + + + a + a;

System.out.println (a);

  1. Rewrite the following program segment using the if-else statements.

String grade = (mark>=90) ? “A” : (mark>=80) ? “B” : “C”;

  1. 5. State one difference between floating point literals float and double.

Question 4.                                                                                                   [5*2=10]

  1. Write a java expression for the following.

Y= √c3-a2+b9

  1. What are the final values stored in x and y below?

double a=  -2.15;

double b= 29.87;

double x=Math.abs(Math.floor(a));

double y=Math.rint(Math.min(a,b));

  1. Give one example each of a primitive data type and a composite data type.
  2. What is the use of default in a switch?
  3. Explain the term object with example?

SECTION B (60 Marks)

Attempt any four questions from this Section.

The answer in the Section should consist of the Program in BlueJ environment with Java. Each program should be written using Variable descriptions/Mnemonic Codes such that the logic of the program is clearly depicted. Flow-Charts and Algorithms are not required.

 

Question 5                                                                                                                              [15]

Write a program to generate the following pattern.       

  1. *****

****

***

**

*

  1. 1

1 2

1 2 3

1 2 3 4

1 2 3 4 5

 Question 6                                                                                                                                  [15]

Write a class in java to enter any number and print if it is a perfect number.[Hint: a number is said to be perfect if it is equal to sum of all its factors ex, 6=1+2+3, hence 6 is perfect number]

 Question 7.                                                                                                                                                                               

  1. Using switch case create class which take month number 1-12 and prints the corresponding month in words [3- March, 12-December]                 [7]
  2. b. Write a class to input a number and print if it is a prime number or not.                 [8]

 Question 8.                                                                                                                               [15]

 

Question 9.                                                                                                                    [15]

Create overloaded methods named void calc_Area ( ), that has been overloaded to perform the following functions

  • Area of circle
  • Area of Rectangle

Write a menu driven program in Java to display the above 2 menus and execute the overloaded methods and display the Area in the respective functions,

calc_Area (double) for Circle,

calc_Area (double, double) for Rectangle

[Area of circle=πr2, Area of rectangle=width * height]

 

Question 10.                                                                                                                                                                      [15]

Define a class named movieMagic with the following description: Instance variables/Data members

int year                               –                            to store the year of release of a movie

String title                         –                            to store the title of the movie float rating                        –                                  to store the popularity of a movie

(minimum rating = 0.0 and maximum rating = 5.0)

Member methods

  1. i) void accept()                            To input and store year, title and rating.
  2. ii) void display()                            To display the title of a movie, the year of release and a message based on the rating as per the table below:

Rating                                                               Message to be displayed

0.0 to 2.0                                                         Flop

2.1 to 3.4                                                         Semi-hit

3.5 to 4.5                                                         Hit

4.5 to 5.0                                                         Super hit

Write a main method to create an object of the class and call the above member methods.

 

LEAVE A REPLY

Please enter your comment!
Please enter your name here