Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!