We are here with you hands in hands to facilitate your learning & don't appreciate the idea of copying or replicating solutions. Read More>>


Looking For Something at vustudents.ning.com? Click Here to Search

Assignment No. 02
SEMESTER Spring 2016
CS508- Modern Programming Languages

 

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:

  • The assignment is submitted after due date.
  • The submitted assignment does not open or file corrupt.
  • The assignment is full or partially copied from (other student or ditto copy from handouts or internet).
  • Student ID is not mentioned in the assignment File or name of file is other than student ID.
  • The assignment is not submitted in .doc or .docx format.

Uploading instructions

Your submission must include:

 

  • Assignment should be in .doc or .docx format.
  • Save your assignment with your ID (e.g. bx020200786.doc).

Assignment submission through email is NOT acceptable

Objective

The objective of this assignment is

 

  • To be able to understand different concepts of JAVA programming language.

 

Note:

Your answer must follow the below given specifications.

  •  Font style: “Times New Roman”
  •  Font color: “Black”
  •  Font size: “12”
  •  Bold for heading only.
  •  Font in Italic is not allowed at all.
  •  No formatting or bullets are allowed to use.
  • Your answer should be precise and to the point, avoid irrelevant detail.

 

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.

  1. Bank_accounts   (Base class)
  2. Saving_Account (Subclass of Bank_accounts)
  3. Saving_Acc_Test (main function class)

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.

+ Click Here To Join also Our facebook study Group.

..How to Join Subject Study Groups & Get Helping Material?..


See Your Saved Posts Timeline

Views: 2063

.

+ 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?)

Replies to This Discussion

java ki file shARE please

This is Assignment # 2

Inheritance

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.

Overriding Members

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 overridekeyword 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

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 

Attachments:

changing kar la ni
thanks

ya solution theak ha
changing kar lani

Attachments:

solution plz

is me error hai

kon sa

ideone par run ki error a rha hai

RSS

Latest Activity

Profile IconAnabia maliik, S u N nY, Muzammil and 2 more joined Virtual University of Pakistan
21 minutes ago
S u N nY updated their profile
45 minutes ago
M Salman khan posted a status
"Hum Woh Hain Jo Aankhon Mein Jhaank Ke Sach Jaan Lete Hain, Mohabbat Hai Isliye Tere Jhoothh Ko Sach Maan Lete Hain"
59 minutes ago
M Salman khan posted a status
"Teri Mohabbat Ko Kabhi Khel Nahi Samjha, Varna Khel Toh Itne Khele Hain Ki Kabhi Haare Nahi."
1 hour ago
ملالٖ یار updated their profile
1 hour ago
muhammad saqib liked Fari Malik's profile
1 hour ago
Fari Malik and Rain Drop are now friends
1 hour ago
+ "αяsαℓ " Ќąƶµяɨ •" replied to + + + " Alif " + + +'s discussion Must Read Every Student Who Want To Get Gud Marks In Exams
1 hour ago

© 2019   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service