/* Chapter 11 - Practise Set 1... Create an abstract class Pen with methods Write () and refill 1) as abstract methods 2... Use the Pen Class from Q1 to create a Concrete class fountain Pen with additional method change Nibl) 3...Create a class Monkey with jump () and bitel) methods. Create a class Human which inherits this Monkey class and implements Basic Animalinterface with eati) and sleep methods. 4.... Greate a class Telephone with ring() liftus and disconnect ( methods as abstract methods Create another class Smart Telephone and demonstratepolymorphism 5.....Demonstrate polymorphism Msing monkey class from Quess 3. 6.......Create an Interface TV Remote and use it to inheritanother Interface Smart Tv Remote 7...... Create a Class Tv which implements Tv Remote interface qsn 6 */ package com.company ; //programe 1 abstract class Pen { abstract void Write (); abstract void Refill (); } //programe 2 class FountainPen extends Pen { void ...
questions: /* 1. Create a class Employee with the following properties and methods: Salary (property) (int) getSalary (method returning int) name (property) (String) getName (method returning String) setName (method changing name) 2. Create a class cellphone with methods to print “ringing…”, “vibrating…”, etc. 3. Create a class Square with a method to initialize its side, calculating area, perimeter etc. 4. Create a class Rectangle & problem 3. 5. Create a class TommyVecetti for Rockstar Games capable of hitting (print hitting…), running, firing, etc. 6. Repeat problem 4 for a circle. */ answers package com.company; class Employee{ int salary; String name; public int getSalary(){ return salary; } public String getName(){ return name; } public void setName(String n){ name = n; } } class CellPhone{ public void ring(){ System.out.p...
//implement a library using java class library //methods: issuebook,returnbook,showavailablebooks //properties:to store available books,store issued books //exercise 4 package com.company ; class library { String [] books ; int no_of_books ; library () { this . books = new String[ 100 ]; this . no_of_books = 0 ; } void addbook ( String book) { this . books [ no_of_books ] = book; no_of_books ++; System . out .println(book + ".... has been added....." ); } void showavailablebooks () { System . out .println( "available books are :" ); for ( String book : this . books ) { if ( book == null ) { //break;------//issue book jdi null hoye jy tale porer books shor krbe na tai continue continue ; } System . out .println( "*..." + book ); } } void issuebook ( String book) { //for (String b:th...
Comments
Post a Comment