Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q1/ What is the output for the following program codes? a) [ 0.5 Mark ] class A { int i; } class B extends A

Q1/ What is the output for the following program codes? 
a) [ 0.5 Mark ] 
 class A { 
 int i; 
 } 
 class B extends A { 
 int j; 
 void display() { 
 super.i = j + 1; 
 System.out.println(j + " " + i); }} 
 class inheritance { 
 public static void main(String args[]) { 
 B obj = new B(); 
 obj.i=1; 
 obj.j=2; 
 obj.display(); }} 
 
b) [ 0.5 Mark ] 
 class Parent { 
 public void getBike(){ 
 System.out.println("Suzuki Bike"); 
 }} 
 class Child extends Parent { 
 public void getCar(){ 
 System.out.println("Swift car"); }} 
 class inheritance { 
 public static void main(String args[]) { 
 Parent p = new Parent(); 
 p.getBike(); 
 Child c = new Child(); 
 c.getBike(); 
 c.getCar(); }} 

---------

Q2/ a) Provide the UML diagram for the following program. [ 0.5 Mark ] 
class Parent { 
 public void getBike(){ 
 System.out.println("Suzuki Bike"); 
 } 
 } 
 class Child extends Parent { 
 public void getCar(){ 
 System.out.println("Swift car"); 
 } 
 } 
 class inheritance { 
 public static void main(String args[]) 
 { 
 Parent p = new Parent(); 
 p.getBike(); 
 Child c = new Child(); 
 c.getBike(); 
 c.getCar(); 
 } 

}

b) Explain the relationship between the sub class constructor and the super class constructor. Explain different possibilities with the help of an example.

-------------

Q3/

a) Explain the concept of interface in Java with example. [ 0.5 Mark ]

Answer:

b) Mention any five rules for interfaces in Java. Also provide an example for each rule [ 0.5 Mark ]

Answer :

----------------

Q4/

Implement a program for bank application containing two classes (e.g.CurrentAccount and SavingAccount etc ) and an interface(e.g. BankAccount with atleast 3 method signatures.) should be implemented by the above mentioned classes. 
 
Answer. 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management An Organizational Perspective

Authors: Richard T. Watson

1st Edition

0471305340, 978-0471305347

More Books

Students also viewed these Databases questions

Question

What is a contingency table with fixed marginals?

Answered: 1 week ago

Question

Define Management or What is Management?

Answered: 1 week ago

Question

What do you understand by MBO?

Answered: 1 week ago

Question

4. Describe the factors that influence self-disclosure

Answered: 1 week ago

Question

1. Explain key aspects of interpersonal relationships

Answered: 1 week ago