Location via proxy:
[ UP ]
[Report a bug]
[Manage cookies]
No cookies
No scripts
No ads
No referrer
Show this form
Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
39 views
Computer java constructor program for practice
For icse class 10 java constructor program
Uploaded by
shivkantimishra11
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Computer java constructor program for practice For Later
Download
Save
Save Computer java constructor program for practice For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
39 views
Computer java constructor program for practice
For icse class 10 java constructor program
Uploaded by
shivkantimishra11
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Computer java constructor program for practice For Later
Carousel Previous
Carousel Next
Save
Save Computer java constructor program for practice For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 5
Search
Fullscreen
Beas 3 Q-1! Q.1: Tick the Correct Option for the Following Questions : 1. The function defined by the same name as of the elass and initializes the object jg no (©) constructive (b)_ constructor (©) construetion (2) convertor 2. A constructor is commonly divided into default and Constructor (®)_non-parameterized(b) void type (©) parameterized () Integer The return type of a constructor is: (a) int (b) float (©) void (O None of thee The presence of more than one constructor in a class is known as (a) overcoming (b) overriding (©) overlapping () overloading 5. Which of the following is the default constructor name for a class named Result? (a) Result() (b) result() (© Result (result 6. Complete the following statement using suitable term for a class Matches: Matches obj = new (a) Matehes( ); (b) Matches; (© Match(); (@) matehes( ); 7. A constructor is always defined using the access modifier. (a) public (>) Public (©) Private (@)_ protected 8. Which of the following technique is used for constructor invoking? (a) class creation _(b) function creation (c)_ object creation (d)_ member creation 9. Which type of the constructor is created by the compiler in the absence of the constructor? (a) parameterized —(b) object (©) default (@)_non-default 10. A constructor with one or more arguments is known as constructor, (a) default (>) function (©) initialized (d)_ parameterized | Q.2: Answer the Following Questions : 1. What do you mean by a constructor? 2. Name the types of constructors. 3. Define a non-parameterized constructor. Create a non-parameterized constructor to initialize default values to the data members long number and double price for a class Student. 4. What is a parameterized constructor? Create a parameterized constructor to initialize paramelit values to the data members long number and double price for a class Student. 5. State the difference between a constructor and a method, Q.3: Programming Assignments : 1. Define a class Student with the following specifications: Instance variables / data members: int roll_number + to store the roll number of a student, int m1, int m2, int m3 - to store marks obtained in three subjects out of 100 each: int maximum + to store the maximum marks out of m1, m2 and m3. double average ~ to store the average marks, Con’ ridite. yor fine vou id main() to pafine a class Accoun » ieance variables / suring AME Jong acne char tyPC gouble balance double deposit_amt double withdraw_amt Member methods: Account( ) void readData( ) yoid Deposit() yoid Withdraw( ) void show() void main() 3. Define a class Compo (where, P - Prin Instance variables / String name double Pamt double rate int double Cl Member methods: Compound(String 5+ default constructor to initia fi ze to input roll numbe to find the maximu: ° instance variables with default values. and marks in three subjects. m marks and th mi : ; e average s es to print roll number, marks obtai einem nace . obti o create an object of the ed, maximum marks and average. class and call the % " he above member methods. t with the following specifications: : data members: to store the name of account holder. to store the account number, to store the type of account. (S or s for saving account and C or ¢ for current account) to store the balance amount. to store the amount to deposit. to store the amount to withdraw. default constructor to initialize instance variables with default values. to input name of the account holder, account number, type of account and the balance amount. to accept the amount to be deposited and update the balance amount. to accept the amount to without (except rupees 1000, which is minimum balance) and update the balance amount. to print name of thé account holder, account number, type of account and the balance amount. - to create an object of the class and invoke the above member methods. und with the following specifications, using the formula: ty ci=(PatsN IP cipal amount, r - Rate of interest and n - Time period) data members: _ to store the name of the account holder. to store the principal amount. = to store the rate of interest. _ to store the time period. = to store the compound interest. double p, double #, int #)- parameterized constructor to assign instance tides nase = 6, Pant = @ te = Fe eS void Interest( ) - to find the compoun void Print( ) - to display name of accoun void main( ) - to create an object ofthe class an‘ 4 interest using the formula given above and store in CI. + holder and compound interest. 4 invoke the above member methods.x 4. Define a class Salary with the following specifications: Instance variables / data members: to store the name of the employee, name he salary to store the salary of the employee i ing years to store the duration of service, ls totalSal to store the total salary of the employee, Member methods: Salary(String n, int y, double s) - parameterized constructor to assign instang, name = n, years = y and salary = 5, e Veta, to calculate the total salary (totalSal) ing, i bonus amount. The bonus will be evaluated ing following rule: sing yt void calculate() Years Bonus amount (in Rupe 1to5 1000.0 a) 6 to 10 2500.0 11 to 20 4000.0 21 and above 5000.0 to print the name of the employee, duration of service and total. Salay, void display() to create an object of the class and invoke the above member mein, void main() : 5. Define a class Employee with the following specifications: Instance variables / data members: empname - to store the name of the employee. eno - to store the employee number. age - to store the age of the employee. basic - to store the basic salary. eclare the instance variables using appropriate data types) Member methods: Employee( ) void Input() - to accept the details of the employee. void Compute() - _to calculate the net salary of the employee as per the given details netSal = (basic + HRA + DA) - pf, where \ DA = 31% of basic. | HRA = 15% of basic. pf = 10% of basic An additional allowance of Rs. 5000.0 will be added to the net s2l3"! (netlSal) if the age of the employee is above 50 years. constructor to initialize data members with default initial values. | void display() - to print all the details of the employee with appropriate ee void main() - tocreate an object of the class and invoke the above member bet al Ics 6. Define a class movieMagic with the following descriptions: Instance variables / data members: String title : to store the title of the movie. int year 7 to store the year of the release of a movie. eS constrWrite a main() to create an object of the class and call the i. ity rating of the movie. = 0.0 and maximum rating = 5.0) to store the Popular; (minimum rating default const Tuctor to initializ ‘ data member to", "Halize numeric data members to 0 and String to input and store title to print the ti on the he title of the movie, year of release and a message based nunE 28 per the table given below: year and rating. Rating Message to be displayed 0.0 to 2.0 Flop 2.1 to 3.4 Semi-hit 3.5 to 4.5 Hit 4.6 to 5.0 Super-hit above member methods. Define a class ParkinglLot with the following descriptions: ICSE 2015 Instance variables / data members: int vno - int hours - double bill - Member methods: ParkingLot( ) : void accept( ) void calculate( ) void display() o to store the vehicle number. to store the number of hours the vehicle is parked in the parking lot. to store the bill amount. default constructor to initialize the data members. to input and store the vno and hours. to calculate the bill amount at the rate of Rs. 8 for the first hour or part thereof, and Rs. 1.50 for each additional hour or part thereof. to display vno, hours and bill with appropriate messages. Write a main( ) to create an object of the class and call the above member methods. 8. Define a class BookFair with the following descriptions: ICSE 2016 Instance variables / data members: BookFair( ) String Bname - double price - Member methods: BookFair( ) : void accept( ) : void calculate() — - void Play() 2 Write a main( ) - Beuctors default constructor to initialize the data members. to store the name of the book. to store the amount to be paid. default constructor to initialize the data members to input and store name and price of the book. to calculate the price after the discount. The discount is calculated on the given criteria: Price Discount Less than or equal to Rs. 1000 2% of price More than Rs. 1000 and less than or equal to 3000 10% ofprice More than Rs. 3000 15% ofprice to display the name and price of the book after the discount. to create an object of the class and call the above member methods.wy 9. 10. Define a class ElectricityBill with the following descriptions: Ica Instance variables / data members: : String n to store the name of the customer. int units - to store the number of units consumed. double bill = tostore the amount to be paid. Member methods: ElectrictBill() - void accept() - void calculate( )- default constructor to assign instance variables with default yay, to input name of the customer and number of units consumed. to calculate the bill as per the slabs given below: Number of units Rate per unit First 100 units = 2.00 Next 200 units % 3.00 % 5.00 Above 300 units A surcharge of 2.5% is charged, if the number of units consumes is above 300 void print() — - to display the details in the following format: Name of the customer : Number of units consumed :. Bill amount : a aettarere Write a main( ) to create an object of the class,and invoke the above member methods, Define a class ShowRoom with the following descriptions: ICSE 2019 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 item purchased. double dis + to store the discount amount. double amount _- _to store the amount to be paid after the discount. Member methods: ShowRoom() —- _ default constructor to assign _ instance variables with default values, void input() —- to input customer name, mobile number and cost. void caleculate() - to calculate the discount on the cost of purchased item, based onthe | criteria given below: Cost Discount (in percentage) Less than or equal to Rs. 10000 5% More than Rs. 10000 and less than or equal to 20000 = 10% More than Rs. 20000 and less than or equal to 35000 = 15% More than Rs. 35000 20% void display() - to print the customer name, mobile number and amount to be paid aflet the discount. Write a void main( ) to create an object of the class and invoke the above member metho
You might also like
Topic: Evolution of Java, Java Architecture, Language Basics, Flow Control
PDF
25% (4)
Topic: Evolution of Java, Java Architecture, Language Basics, Flow Control
15 pages
File Assignment 1. Chap Functions
PDF
No ratings yet
File Assignment 1. Chap Functions
7 pages
Constructors and Class&Objects
PDF
No ratings yet
Constructors and Class&Objects
6 pages
non paramertized questions
PDF
No ratings yet
non paramertized questions
6 pages
Constructor and Functions Based Programs
PDF
No ratings yet
Constructor and Functions Based Programs
3 pages
UNIT TEST-2 2021-22 Class: Xii Computer Science: SECTION: A (7 Marks)
PDF
No ratings yet
UNIT TEST-2 2021-22 Class: Xii Computer Science: SECTION: A (7 Marks)
4 pages
Object Oriented New
PDF
No ratings yet
Object Oriented New
7 pages
Inheritance
PDF
No ratings yet
Inheritance
5 pages
constructors
PDF
No ratings yet
constructors
8 pages
Ch#11 Constructors
PDF
No ratings yet
Ch#11 Constructors
15 pages
X - Classes and Objects 1-4
PDF
No ratings yet
X - Classes and Objects 1-4
4 pages
Class and Object Programs-Past Papers
PDF
No ratings yet
Class and Object Programs-Past Papers
6 pages
Solve The Following Problems Using Java Programs
PDF
No ratings yet
Solve The Following Problems Using Java Programs
3 pages
CHAPTER 6 PROGRAMS
PDF
No ratings yet
CHAPTER 6 PROGRAMS
26 pages
Class Assignment5 Xi
PDF
No ratings yet
Class Assignment5 Xi
4 pages
Chapter 7 Class As A User Defined Data Type
PDF
100% (1)
Chapter 7 Class As A User Defined Data Type
10 pages
QuestionBank CONSTRUCTOR
PDF
No ratings yet
QuestionBank CONSTRUCTOR
4 pages
10A June
PDF
No ratings yet
10A June
3 pages
The Open University of Sri Lanka Diploma in Technology - Level 3 ACADEMIC YEAR 2007/2008 Mek3170 C Programming Assignment #3
PDF
No ratings yet
The Open University of Sri Lanka Diploma in Technology - Level 3 ACADEMIC YEAR 2007/2008 Mek3170 C Programming Assignment #3
8 pages
Java - 5.1 Constructors PDF
PDF
No ratings yet
Java - 5.1 Constructors PDF
24 pages
Chapter 2 Class As Basis of All Computation
PDF
No ratings yet
Chapter 2 Class As Basis of All Computation
9 pages
Assignment01 1
PDF
No ratings yet
Assignment01 1
2 pages
Icse Project 2023 24(35 Programs) With Answers
PDF
No ratings yet
Icse Project 2023 24(35 Programs) With Answers
24 pages
Adobe Scan 15-Oct-2024
PDF
No ratings yet
Adobe Scan 15-Oct-2024
10 pages
Sushilcpp
PDF
No ratings yet
Sushilcpp
66 pages
Oops Assignment 1
PDF
No ratings yet
Oops Assignment 1
3 pages
X-CTA-Practice Paper 24-25-Solutions-Part-2
PDF
No ratings yet
X-CTA-Practice Paper 24-25-Solutions-Part-2
29 pages
Computer Assignment List
PDF
No ratings yet
Computer Assignment List
4 pages
Practice Worksheet 5
PDF
No ratings yet
Practice Worksheet 5
6 pages
Class Concept Questions
PDF
No ratings yet
Class Concept Questions
11 pages
Programs Statements
PDF
No ratings yet
Programs Statements
9 pages
ICSE 2017 Computer Applications Class X Question Paper (Solved) JAVAPBA
PDF
No ratings yet
ICSE 2017 Computer Applications Class X Question Paper (Solved) JAVAPBA
10 pages
Assgnment No.1
PDF
No ratings yet
Assgnment No.1
3 pages
Final Model Kit Class XII CBSE COMPUTER SCIENCE
PDF
No ratings yet
Final Model Kit Class XII CBSE COMPUTER SCIENCE
10 pages
Practice Worksheet 5
PDF
No ratings yet
Practice Worksheet 5
6 pages
DSA - Lab - 02 - Implementation of Objects and Classes
PDF
No ratings yet
DSA - Lab - 02 - Implementation of Objects and Classes
7 pages
Java Lab Manul - Merged
PDF
No ratings yet
Java Lab Manul - Merged
115 pages
Adobe Scan 02 Jul 2023
PDF
No ratings yet
Adobe Scan 02 Jul 2023
3 pages
Icss Class 10 Computer Application Important Programs SM2
PDF
No ratings yet
Icss Class 10 Computer Application Important Programs SM2
97 pages
Mid Term Question 233 CSE1115 a MNK-1
PDF
No ratings yet
Mid Term Question 233 CSE1115 a MNK-1
4 pages
Dms - 65698bef9586ajava Assignment4
PDF
No ratings yet
Dms - 65698bef9586ajava Assignment4
2 pages
Design a class with the following specifications
PDF
No ratings yet
Design a class with the following specifications
3 pages
Assignment 01 Fall 2020
PDF
No ratings yet
Assignment 01 Fall 2020
12 pages
Exercise Lecture One OOP
PDF
No ratings yet
Exercise Lecture One OOP
2 pages
Ctood Assignment2
PDF
No ratings yet
Ctood Assignment2
59 pages
Grade 10 Journal Questions 24-25
PDF
No ratings yet
Grade 10 Journal Questions 24-25
12 pages
Programming Assignment V
PDF
No ratings yet
Programming Assignment V
5 pages
Constructor Based Programming
PDF
No ratings yet
Constructor Based Programming
3 pages
Assignment for first term- grade 10
PDF
No ratings yet
Assignment for first term- grade 10
3 pages
JAVA Programs Part 2
PDF
No ratings yet
JAVA Programs Part 2
4 pages
Pre Selection Comp Project
PDF
No ratings yet
Pre Selection Comp Project
39 pages
CHAPTER_CONSTRUCTOR_CLASS_X
PDF
No ratings yet
CHAPTER_CONSTRUCTOR_CLASS_X
32 pages
Nishanth X D Computer Applications Home Test
PDF
No ratings yet
Nishanth X D Computer Applications Home Test
11 pages
Object Oriented Programming Exercises
PDF
No ratings yet
Object Oriented Programming Exercises
13 pages
COMPUTER APPLICATIONSCL-10 2023-24 PREBOARD (1)
PDF
No ratings yet
COMPUTER APPLICATIONSCL-10 2023-24 PREBOARD (1)
6 pages
Programming With Java_Index for Termwork File
PDF
No ratings yet
Programming With Java_Index for Termwork File
8 pages
Computer Assignment
PDF
No ratings yet
Computer Assignment
5 pages
Adobe Scan Dec 06, 2023
PDF
No ratings yet
Adobe Scan Dec 06, 2023
23 pages