Java Practical No.17.pdf

  • Uploaded by: Meer Kukreja
  • 0
  • 0
  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Java Practical No.17.pdf as PDF for free.

More details

  • Words: 259
  • Pages: 6
17.1) Develop a program to extend ‘dog’ from ‘animal’ to override ‘move()’ method using super keyword. PROGRAM: import java.util.*; class dog { String name; int age; Scanner s = new Scanner(System.in);

void move() { System.out.println("Enter Name = "); name = s.next();

System.out.println("Enter Age = "); age = s.nextInt(); } void dis() { System.out.println("Name of Dog = "+name); System.out.println("Age of Dog = "+age); } } class animal extends dog { String breed;

void move() { super.move(); System.out.println("Enter breed = "); breed = s.next(); } void put() { System.out.println("Breed of Dog = "+breed); } } class animalD { public static void main(String args[]) { animal a = new animal(); a.move(); a.dis(); a.put(); } }

OUTPUT:

17.2) Develop a program of class book with data members author, title, publisher & method show and class bookinfo having data members of price, stack, position & method show & display information. PROGRAM: import java.util.*; class book { String au,title; int price; Scanner s = new Scanner(System.in);

void show() { System.out.println("Enter Author name = "); au = s.next();

System.out.println("Enter Title = "); title = s.next();

System.out.println("Enter price = "); price = s.nextInt(); } void display() { System.out.println("Author name = "+au); System.out.println("Title name = "+title);

System.out.println("Price name = "+price); } } class bookinfo extends book { int price , stackP;

void show() { super.show(); System.out.println("Enter Price = "); price = s.nextInt();

System.out.println("Enter Stock Position = "); stackP = s.nextInt(); } void put() { System.out.println("Price = "+price); System.out.println("Stock Position = "+stackP); } }

class bookD { public static void main(String args[]) {

b.show(); b.display(); b.put(); } }

OUTPUT:

Related Documents


More Documents from "Meer Kukreja"