This paper is divided into two sections. You are to answer all the questions from section A, and any four from section B.
Section A (40 marks)
Attempt all questions


  1. a) Write a java statement to compute discount. Divide the variable total by 100.Multiple the result by MP.
    b) Write the function prototype for the function “sum” that takes an integer variable “val” as its argument and return a value of float data type.
    c) Write valid java statements to perform the following on String:
    • Extract 10 characters from the first character to tenth of the string.
    • To print the position of the first occurrence of letter ‘R’ in the string city.
    d) Consider the given array and write a valid java program code to update each element of the array by adding 2.
    int m[]={5,7,9,11,13};
    e) Give the output of the following.
    void Test()
    {
    int a,b;
    for( a=1,b=5;a<5&&b>1;a++,b–)
    {
    System.out.println(a);
    System.out.println(b);
    }
    }

  2. a) Write a java expression for the following.
    X=-b+√ b4-4ac/2a
    b) Give the output of the following.
    charch;
    int x=97;
    do
    {
    ch=(char)x;
    Sytem.out.println(ch+” “);
    if(x%10==0)
    break;
    x=x+1;
    }
    While(x<=100);
    c) Explain the feature of OOPs which means ‘reusabilty’ .
    d)
    I. Name the mathematical function which is used to find the cosine of an angle given in radians.
    II. Name a string function which removes the blank spaces provided in the prefix and suffix of a string.
    e) Rewrite the following statement using if-else statement.
    amt=(x!=50)?((x<50)?(4.0/100x): (10.0/100x):500;

a) Write a statement to show how finding the length of a character array char[] differs from finding the length of a string object str;
b) Evaluate the following expression , if the values of the variable are :
int p, k=8, m=11,r=7;
p=(r++%7)+(–m%5)+k*(++k-8)
c) Write java statements for the following tasks.
i) To convert string number stored in variable ‘z’ to double type.
ii) To convert a character ch to lowercase.
d) Name any two tokens of java.
e) What are the different keywords that check the visibility of a member of the class? What are they called?
f) Explain constructor overloading.
g) Explain any one primitive and one non primitive data member.
h) What is an exception? Name two blocks used in exception handling.
i) Write the output of the following.
String a=”Thugs of Hindustan”;
String b=”Water Resources”;
System.out.println(”J”.concat(a.subString(2,9).concat(b.susbstring(0,5))));
System.out.println(b.indexOf(b.charAt(7));
j)
i) Name any two packages of java.
ii) Name any two wrapper classes.
Section B
Attempt any 4 questions from this section
Each program should be written using a variable list so that the logic of the program is clearly depicted.

  1. a) Write a program to enter a binary number and display its decimal equivalent.
    b) Write a program to create function void ispalindrome(int n), to check and print whether ‘n’ is palindrome or not.
  2. a) Write a program to generate the sum of the following series

b) Write a program to generate the following pattern
A *
B *C *
D *E *F *
G *H *I *J *
K *L *M *N *O *

  1. Using the switch statement, write a menu driven program :
    i) To check and display whether a number input by the user is a composite number or not (A number is said to be composite, if it has one or more than one factor excluding 1 and the number itself).
    ii) To find the smallest digit of an integer that is input by the user.
    Sample Input : 6524
    Sample output : Smallest digit is 2.
    For an incorrect choice, an appropriate error message should be displayed.
  2. Write a program to input two integer arrays A[] and B[] of m and n size respectively. Create a third array by merging the array A[] followed by array B[].
    Sample input: if A[]={6,15,7,4,9} and B[]={3,24,6}
    Sample Output: C[]={6,15,7,4,9, 3,24,6}
  3. 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
  4. Hero Honda has introduced the cost of its vehicles as per the type of the engine using the following criteria.
    Type of Engine Rate of Increment
    2 stroke 10% of the cost
    4 stroke 12% of the cost
    Define a class Honda to find the new cost as per the given applications:
    Data Members:
    int type – to accept type of engine
    Int cost—to accept previous cost
    Member Methods:
    void gettype(): To accept the type of engine and the cost.
    void find(): To find the new cost (increased cost) as per the criteria given above
    void printcost: To print the type and new cost of the vehicle.
    Write a main method to create an object of the class and call the above methods.

LEAVE A REPLY

Please enter your comment!
Please enter your name here