Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java programming Question 1/ What is the output for the following program codes? a) [ 0.5 Mark ] class A { int i; } class

Java programming Question 1/ 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(); }} 

---------

Question 2/ 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.

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

Question 3/

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 :

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

Question 4/

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. 
 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions