This paper is divided into two sections. You are to answer all the questions from section A, and any three from section B.
Section A (20 marks)
Attempt all questions
- What is function overloading? Explain with example.
- What is a package? Give name of any two packages.
- What will be the result stored in Z after evaluating the following expression?
int a=5; Z= (++a*(a–+3));
- Write the Java expressions for:
- Write a statement
- to create an object of Scanner class called keyboard.
- To take a string as input and assign it to a variable called name.
- What is fall through. Explain with an example.
- What is the purpose of default in switch case
- Explain the job of return keyword?
- Give the difference between call by value and call by reference
- Differentiate hasNextInt() and nextInt()function.
- Give the difference between actual parameter and formal parameter.
Attempt any three programs.
Q 1. Write a menu driven program to find the sum of the following series depending on the user choosing 1 or 2
1. S=1/4+1/8+1/12………+1/n (value of n will be given by the user)
2. S=1/x1+2/x2+3/x3…….+n/xn(value of x and n will be given by the user)
Write a menu driven program:
i) To check and display whether a number input by the user is a palindrome number or not (A number is said to be palindrome, if it remains same after reversing it also. ). Example 121,191,222…..
ii) To find the biggest digit of an integer that is input.
Sample input : 195
Sample output : Biggest digit is 9
For an incorrect choice, an appropriate error should be displayed.
Define a class called Library with the following descriptions.
Instance variables/Data members:
int acc_num stores the accession number of the book.
String title stores the title of the book.
String author stores the name of the author
i) void input() to input and store the accession number, title and author.
ii) void compute() to accept the number of days late, calculate and display the fine
charged at the rate of Rs.2/- per day.
iii) void display() to display the details in the following format.
Accession Number Title Author
Write a main method to create an object of the class and call the above member methods.