Monday, February 24, 2020

WEEK 4 ASSIGNMENT

QUESTION 1:


import java.io.*;
import java.util.*;
import static java.lang.System.*;

QUESTION 2:


// Create an object of Calendar class. 
java.util.Calendar current ;

// Use getInstance() method to initialize the Calendar object.
current = java.util.Calendar.getInstance();

// Initialize the int variable year with the current year
year = current.get(current.YEAR);

QUESTION 3:


interface ExtraLarge{
String extra = "This is extra-large";
void display();
}

class Large {
    public void Print() {
        System.out.println("This is large");
    }
}

class Medium extends Large {
    public void Print() {
      super.Print();  
        System.out.println("This is medium");
    }
}
class Small extends Medium {
    public void Print() {
        super.Print();  
        System.out.println("This is small");
    }
  }


class Question43 implements ExtraLarge{
    public static void main(String[] args) {
        Small s = new Small();
        s.Print();
  Question43 q = new Question43();
  q.display();
    }
  public void display(){
    System.out.println(extra);
  }
}


QUESTION 4:


// Call show() of First interface.
First.super.show();
// Call show() of Second interface.
Second.super.show();

QUESTION 5:


// Interface ShapeX is created
interface ShapeX {
 public String base = "This is Shape1";
 public void display1();
}

// Interface ShapeY is created which extends ShapeX
interface ShapeY extends ShapeX {
 public String base = "This is Shape2";
 public void display2();
}

// Class ShapeG is created which implements ShapeY
class ShapeG implements ShapeY {
 public String base = "This is Shape3";
 //Overriding method in ShapeX interface
 public void display1() {
  System.out.println("Circle: " + ShapeX.base);
 }
 // Override method in ShapeY interface
  public void display2(){
  System.out.println("Circle: " + ShapeY.base);}
}

1 comment:

  1. As claimed by Stanford Medical, It's really the SINGLE reason this country's women get to live 10 years more and weigh 42 lbs less than us.

    (By the way, it has absolutely NOTHING to do with genetics or some secret diet and EVERYTHING to do with "how" they are eating.)

    P.S, What I said is "HOW", and not "WHAT"...

    CLICK this link to see if this quick questionnaire can help you decipher your real weight loss possibility

    ReplyDelete