0% found this document useful (0 votes)
45 views4 pages

Class As A User Define

Compiter

Uploaded by

shubham5026b
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views4 pages

Class As A User Define

Compiter

Uploaded by

shubham5026b
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Home Work :

Choose the correct answer

(a) Find the access specifier which prohibits a class member from being used outside a class:
1. Private
2. Public
3. Protected
4. None of these

(b) Which of the following keywords are used to control access to a class member?
1. Default
2. Abstraction
3. Protected
4. Interface

(c) If no access specifier is mentioned then ___________ specifier is referred by default.


1. default
2. private
3. protected
4. public

(d) Scope of local variable is with in a class.


1. true
2. false

(e) Which keyword makes class members accessible outside the class in which they are declared?
1. Private
2. Protected
3. Public
4. Hidden

f) Find the access specifier which prohibits a class member from being used outside a class:
1. Private
2. Public
3. Protected
4. None

g) A class object is also known as:


1. Identifier
2. Instance
3. Specifier
4. Modifier

h) Which of the following statements is the most appropriate for the private members?
1. They are visible out of the class in which they are defined.
2. They can be used in the sub-classes.
3. They are only visible in the class in which they are declared.
4. None of the above.

i) Which of the following keywords are used to control access to a class member?
1. Default
2. Abstraction
3. Protected
4. Interface
j) Which of the members can be accessed globally?
1. private
2. public
3. protected
4. All of the above

k) The maximum number of objects of a class can be created as:


1. 1
2. 2
3. On the user's choice
4. Number of variables

l) A class contains:
1. Attributes and methods
2. A number of object of same types
3. Data and member function
4. All of the above

m) Which of the following features is not the principle of OOP?


1. Encapsulation
2. Transparency
3. Inheritance
4. Polymorphism

n) A package is a:
1. collection of data.
2. collection of functions.
3. collection of classes.
4. a nested class.

o) Consider the following code and answer the questions that follow:
class academic
{
intx,y;
void access( )
{
inta,b;
academic student=new academic( );
System.out.println("Object Created");
}
}
(i) What is the object name of the class?
1. academic
2. student
3. access
4. None of these
(ii) Name the instance variables used in the class.
1. x, y
2. a, b
3. both of the above
4. none of these
(iii) Write the name of local variables used in the program.
1. x, y
2. a, b
3. both of the above
4. none of these
p) What should be the execution order, if a class has a method, static block, instance block, and constructor, as
shown below?
public class First_C {
public void myMethod()
{
System.out.println("Method");
}
{
System.out.println(" Instance Block");
}
public void First_C()
{
System.out.println("Constructor ");
}
static
{
System.out.println("static block");
}
public static void main(String[] args)
{
First_C c = new First_C();
c.First_C();
c.myMethod();
}
}
1. Instance block, method, static block, and constructor
2. Method, constructor, instance block, and static block
3. Static block, method, instance block, and constructor
4. Static block, instance block, constructor, and method

Solve the following Program :


1) Define a class Employee having the following description:
Data Members Purpose

int pan To store personal account number

String name To store name

double taxincome To store annual taxable income

double tax To store tax that is calculated

Member functions Purpose

void input() Store the pan number, name, taxable income

void cal() Calculate tax on taxable income

void display() Output details of an employee


Calculate tax based on the given conditions and display the output as per the given format.
Total Annual Taxable Income Tax Rate

Up to ₹2,50,000 No tax

From ₹2,50,001 to ₹5,00,000 10% of the income exceeding ₹2,50,000

From ₹5,00,001 to ₹10,00,000 ₹30,000 + 20% of the income exceeding ₹5,00,000


Total Annual Taxable Income Tax Rate

Above ₹10,00,000 ₹50,000 + 30% of the income exceeding ₹10,00,000


Output:
Pan Number Name Tax-Income Tax
.......... .... .......... ...
.......... .... .......... ...

2) Define a class Discount having the following description:

Data Members Purpose

int cost to store the price of an article

String name to store the customer's name

double dc to store the discount

double amt to store the amount to be paid

Member functions Purpose

void input() Stores the cost of the article and name of the customer

void cal() Calculates the discount and amount to be paid

void display() Displays the name of the customer, cost, discount and amount to be paid

Write a program to compute the discount according to the given conditions and display the output as per the
given format.

List Price Rate of discount

Up to ₹5,000 No discount

From ₹5,001 to ₹10,000 10% on the list price

From ₹10,001 to ₹15,000 15% on the list price

Above ₹15,000 20% on the list price

Output:

Name of the customer Discount Amount to be paid


.................... ........ .................
.................... ........ .................

You might also like