Section A (40 marks)
A. Answer the following questions. [5X2=10]

  1. Define abstraction with example.
  2. What will be the output of the following code?
    double c=100;
    while(c>20)
    {
    System.out.println(“value: :”+c);
    c-=20;
    }
  3. State two harms caused by software piracy.
  4. What is the difference between entry controlled and exit controlled loop?
  5. Write two java keywords.
    B. Answer the following questions. [5X2=10]
  6. What do you mean by Intellectual property rights?
  7. What will be the value of b and c when n1=10 and n2=0, given that
    int b=(n1>n2)? N1:n2;
    double c=(n2!=0)? (n1/n2):n1*2);
  8. Differentiate between OOP and POP.
  9. Find out the errors from the given code.
    for(Q==1;Q<=100;Q==Q+10)
  10. Rewrite the following code using ternary operator.
    if(a<24)
    P=12;
    else
    P=48;
    C. Answer the following questions. [10X2=20]
  11. What will be value of a and b
    a =Math.floor(2.26)
    b=Math.ceil(6.38)
  12. What will be the value of k and a , after the given statements are executed?
    A=20, k=15
    K=k + a++ + ++a/2;
  13. Write two rules of naming an identifier.
  14. Write the following code with if …else
    switch(val)
    {
    case 10:
    System.out.println(“Yellow”);
    break;
    default: System.out.println(“Red”);
    }
  15. Write the java expression for the following
    a2+b2/4ab
  16. Name all types of errors.
  17. Explain the jump statements break and continue.
  18. What is a package? Name any two packages of java.
  19. What is type casting?

  20. • What is the size of long and byte datatype?
    • What are the default values of int and boolean?

Section B (60 marks)
Write JAVA Programs
with Dry run and output of the program.
(Attempt any four) [4X15= 60]

  1. Write a program to Display the following patterns. [15]
    a.
    1
    2 2
    3 3 3
    4 4 4 4
    5 5 5 5 5
    b.
    3 4 5 6 7
    3 4 5 6
    3 4 5
    34
    3
  2. [15]
    a. Write a program to display the sum of following series.
    Sum= 1+1/2+1/3+……+1/n

b. Write a program to display the following series
3 6 9 12 15 18

  1. Design a menu driven program, that accepts an integer and displays the following menu :
    i. Displays the sum of the digits of the numbers.
    Example : 12
    The sum of digits is: 3 [7]
    ii. A number that is smaller than the sum of its factors excluding the number itself is said to be an abundant number.
    Example number: 12
    Sum of its factors excluding the highest factor: 1+2+3+4+6=16
    Write a program to accept a number from the user and print whether it is an abundant number or not. [8]
  2. Design a menu driven program, that accepts an integer and displays the following menu.
    I. Write a program to accept a number from the user and print whether it is an Spy number
    or not. (A number is spy number if the sum of the digits equal to the product of the digits)
    II. Write a program to ask user to generate all the odd numbers within the range.
    (The range will be given by the user).
    For example: 10 to 20
    Output: 11 1315 1719
  3. Create a menu driven program to perform the following operations.
    Enter A for Addition
    Enter Sfor Subtraction
    Enter M for Multiplication
    Enter D for Division
    Enter R for Remainder
    Enter E forExit
    The user will input the character of each option to perform the relevant action.
    e.g., selection D should invoke the Division operation.
    The inputs should be taken after selecting the option.
    Example output:
    Enter A for Addition
    Enter S for Subtraction
    Enter M for Multiplication
    Enter D for Division
    Enter R for Remainder
    Enter E for Exit
    A
    Enter first number
    23
    Enter second number
    15
    The sum of the numbers is: 38

  4. SNV Company gives discount on the amount of the goods sold as per the following table. Write a program in java which accepts the product price and the number of units sold. Calculate the amount of discount applicable and the amount payable.
    Total Cost Discount Rate

=Rs. 10,000 7.5%
=Rs. 5000<Rs. 10000 5%
=Rs. 3000<Rs. 5000 3.5%
=Rs. 2000 <Rs. 3 000 2%
<2000 1%

LEAVE A REPLY

Please enter your comment!
Please enter your name here