NPTEL Programming in Java Week4 Assignment-4 Solutions 2021 | Swayam

Gaming Mouse with 3.9 to 4.00 rating


       
               

Zinq Technologies 1070 3200 DPI LED Backlight 6 Button USB Gaming Mouse with Nylon Braided Cable (Black)


Rating - 3.9 to 4

Price - 400₹ to 500₹

for latest information click - https://amzn.to/2Ow6dXD



 Week-4

Assignment -4

=================================

File name- Question41.java

import java.util..Scanner;

import static java.lang.System.*;


File name- Question42.java

public class Question42{

    public static void main(String args[]){

        int year;

        java.util.Calendar c;

        c=java.util.Calendar.getInstance();

        year=c.get(c.Year);

    }

}


File name- Question43.java

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);

    }

}


File name- Question44.java

First.super.show();

Second.super.show();


File name- Question45.java

// Interface ShapeX is created

interface ShapeX {

 public String baseX = "This is Shape1";

 public void display1();

}


// Interface ShapeY is created which extends ShapeX

interface ShapeY extends ShapeX {

 public String baseY = "This is Shape2";

 public void display2();

}


// Class ShapeG is created which implements ShapeY

class ShapeG implements ShapeY {

 public String baseG = "This is Shape3";

 //Overriding method in ShapeX interface

 public void display1() {

  System.out.println("Circle: " + baseX);

 }

 // Override method in ShapeY interface

 public void display2() {

  System.out.print("Circle: " + baseY);

 }

}


// Main class Question 

public class Question45{

 public static void main(String[] args) {

  //Object of class shapeG is created and display methods are called.

  ShapeG circle = new ShapeG();

  circle.display1();

  circle.display2();

 }

}

No comments:

Powered by Blogger.