+ Link For Assignments, GDBs & Online Quizzes Solution |
+ Link For Past Papers, Solved MCQs, Short Notes & More |
Assignment No. 02 |
Total Marks: 20
Due Date: 20/07/2016 |
|
Instructions Please read the following instructions carefully before solving & submitting assignment: It should be clear that your assignment will not get any credit if:
Uploading instructionsYour submission must include:
Assignment submission through email is NOT acceptable ObjectiveThe objective of this assignment is
Note: Your answer must follow the below given specifications.
Lectures Covered: This assignment covers Lecture # 27 - 30 Deadline Your assignment must be uploaded/submitted at or before 20/07/2016.
|
Question: 20 marks
JAVA is purely object oriented programming language which means every variable, constant and function (method) including main function must be in some class. Furthermore, Java support only single inheritance and each supper class method except its constructors can be inherited, overloaded, or overridden in the subclass.
You are required to write a JAVA program which contains the following three classes.
The base class Bank_accounts should define the attributes/variables for account title, Balance, interest (interest should be in amount).
The base class must contain the methods Withdraw(), Deposit() and add_interest().
The subclass Saving_Account should define an attribute for interest rate (Annual interest in percentage). This class should inherit Withdraw() method, overload Deposit() method and override add_interest () method of base class. Furthermore, the deposit method should deposit some interest (in percentage) on each deposit to saving account and add_inerest method should calculate annual interest on the basis of interest rate.
Saving _Acc_Test class should have main function and define one object of Saving_Account class and one reference of Bank_accounts class pointing to Saving_Account class object, then call these methods of base class and subclass to implement the concept of inheritance, overloading, overriding and polymorphism.
You may add constructors and getter/setter functions in your classes as per your requirements.
Hint: You may set any value for initial balance and deposit/withdraw any amount through these methods. Furthermore, you may call deposit method of base class with derived class object, overloaded deposit method with this object, and withdraw method to implement inheritance and overloading. Similarly call the override method with base class reference to implement overriding and polymorphism.
Note 1: You can compile/check your program online through the link http://www.ideone.com/ for syntax errors.
Note 2: Once you complete assignment, upload your code in a single MS word (.doc or .docx) file on VULMS.
Tags:
+ http://bit.ly/vucodes (Link for Assignments, GDBs & Online Quizzes Solution)
+ http://bit.ly/papersvu (Link for Past Papers, Solved MCQs, Short Notes & More)
+ Click Here to Search (Looking For something at vustudents.ning.com?) + Click Here To Join (Our facebook study Group)java ki file shARE please
This is Assignment # 2
All classes in Kotlin have a common superclass Any
, that is a default super for a class with no supertypes declared:
class Example // Implicitly inherits from Any
Any
is not java.lang.Object
; in particular, it does not have any members other than equals()
,hashCode()
and toString()
. Please consult the Java interoperability section for more details.
To declare an explicit supertype, we place the type after a colon in the class header:
open class Base(p: Int) class Derived(p: Int) : Base(p)
If the class has a primary constructor, the base type can (and must) be initialized right there, using the parameters of the primary constructor.
If the class has no primary constructor, then each secondary constructor has to initialize the base type using the super keyword, or to delegate to another constructor which does that. Note that in this case different secondary constructors can call different constructors of the base type:
class MyView : View { constructor(ctx: Context) : super(ctx) { } constructor(ctx: Context, attrs: AttributeSet) : super(ctx, attrs) { } }
The open annotation on a class is the opposite of Java’s final: it allows others to inherit from this class. By default, all classes in Kotlin are final, which corresponds to Effective Java, Item 17: Design and document for inheritance or else prohibit it.
As we mentioned before, we stick to making things explicit in Kotlin. And unlike Java, Kotlin requires explicit annotations for overridable members (we call them open) and for overrides:
open class Base { open fun v() {} fun nv() {} } class Derived() : Base() { override fun v() {} }
The override annotation is required for Derived.v()
. If it were missing, the compiler would complain. If there is no open annotation on a function, like Base.nv()
, declaring a method with the same signature in a subclass is illegal, either with override or without it. In a final class (e.g. a class with no open annotation), open members are prohibited.
A member marked override is itself open, i.e. it may be overridden in subclasses. If you want to prohibit re-overriding, use final:
open class AnotherDerived() : Base() { final override fun v() {} }
Overriding properties works in a similar way to overriding methods. Note that you can use the override
keyword as part of the property declaration in a primary constructor:
open class Foo { open val x: Int get { ... } } class Bar1(override val x: Int) : Foo() { }
You can also override a val
property with a var
property, but not vice versa. This is allowed because aval
property essentially declares a getter method, and overriding it as a var
additionally declares a setter method in the derived class.
solution please
Please Discuss here about this assignment.Thanks
Our main purpose here discussion not just Solution
We are here with you hands in hands to facilitate your learning and do not appreciate the idea of copying or replicating solutions.
Muhammad Abra Alyas
solution
cs508
changing kar la ni
thanks
ya solution theak ha
changing kar lani
solution plz
is me error hai
kon sa
ideone par run ki error a rha hai
© 2021 Created by + M.Tariq Malik.
Powered by
Promote Us | Report an Issue | Privacy Policy | Terms of Service
We are user-generated contents site. All product, videos, pictures & others contents on site don't seem to be beneath our Copyrights & belong to their respected owners & freely available on public domains. We believe in Our Policy & do according to them. If Any content is offensive in your Copyrights then please email at m.tariqmalik@gmail.com Page with copyright detail & We will happy to remove it immediately.
Management: Admins ::: Moderators
Awards Badges List | Moderators Group
All Members | Featured Members | Top Reputation Members | Angels Members | Intellectual Members | Criteria for Selection
Become a Team Member | Safety Guidelines for New | Site FAQ & Rules | Safety Matters | Online Safety | Rules For Blog Post