Name any two basic principles of Object-oriented Programming.
Concept: Introduction of Object-oriented Programming
Name the keyword which: indicates that a method has no return type.
Concept: Concept of Objects
Name the keyword which: makes the variable as a class variable.
Concept: Concept of Objects
Identify and name the following tokens:
(i) public
(ii) ‘a’
(iii) ==
(iv) {}
Concept: Access Specifiers (Access Modifiers)
Evaluate the following expression if the value of x = 2,y = 3 and z = 1.
v = x + – z + y + + + y.
Concept: Concept of Objects
Design a class name ShowRoom with the following description :
Instance variables/ Data members :
String name – To store the name of the customer
long mobno – To store the mobile number of the customer
double cost – To store the cost of the items purchased
double dis – To store the discount amount
double amount – To store the amount to be paid after discount
Member methods: –
ShowRoom() – default constructor to initialize data members
void input() – To input customer name, mobile number, cost
void calculate() – To calculate discount on the cost of purchased items, based on following criteria
Cost | Discount (in percentage) |
Less than or equal to ₹ 10000 | 5% |
More than ₹ 10000 and less than or equal to ₹ 20000 | 10% |
More than ₹ 20000 and less than or equal to ₹ 35000 | 15% |
More than ₹ 35000 | 20% |
void display() – To display customer name, mobile number, amount to be paid after discount
Write a main method to create an object of the class and call the above member methods.
Concept: Concept of String Class
Name any two OOP’s principles.
Concept: Introduction of Object-oriented Programming
What are identifiers?
Concept: Introduction of Object-oriented Programming
What are keywords ? Give an example.
Concept: Introduction of Object-oriented Programming
Define abstraction.
Concept: Introduction to Wrapper Classes
Name the type of error ( syntax, runtime or logical error) in each case given below:
(i) Math.sqrt (36 – 45)
(ii) int a;b;c;
Concept: Introduction of Object-oriented Programming
What is the difference between the Scanner class functions next () and nextLine()?
Concept: Concept of Objects
Write a function prototype of the following:
A function PosChar which takes a string argument and a character argument and returns an integer value.
Concept: Introduction of Object-oriented Programming
Name any two types of access specifiers.
Concept: Access Specifiers (Access Modifiers)
Give the output of the following string functions:
(i) "MISSISSIPPI".indexOf('S') + "MISSISSIPPI".lastIndexOf('I')
(ii) "CABLE".compareTo("CADET")
Concept: Concept of String Class
System.out.print(“BEST”);
System.out.println(“OF LUCK”);
Choose the correct option for the output of the above statements
Concept: Concept of Objects
Give the output of the following expression:
a+= a++ + ++a + – – a + a – – ; when a = 7
Concept: Introduction of Object-oriented Programming
Give the output of the following string functions :
(i) “ACHIEVEMENT” .replace(E’, ‘A’)
(ii) “DEDICATE”. compareTo(“DEVOTE”)
Concept: Concept of String Class
Using the switch statement, write a menu-driven program for the following:
(i) To print Floyd’s triangle [Given below]
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
(ii) To display the following pattern:
I
I C
I C S
I C S E
For an incorrect option, an appropriate error message should be displayed.
Concept: Introduction of Object-oriented Programming
Design a class Railway Ticket with following description :
Instance variables/data members :
String name: To store the name of the customer
String coach: To store the type of coach customer wants to travel
long mob no: To store customer’s mobile number
int amt: To store a basic amount of ticket
int total amt: To store the amount to be paid after updating the original amount
Member methods
void accept ( )-To take input for a name, coach, mobile number and amount
void update ( )-To update the amount as per the coach selected
(extra amount to be added in the amount as follows)
Type of Coaches | Amount |
First_ AC | 700 |
Second_AC | 500 |
Third _AC | 250 |
sleeper | None |
void display( ) — To display all details of a customer such as a name, coach, total amount and mobile number.
Write a main method to create an object of the class and call the above member methods.
Concept: Concept of String Class