Posts

Showing posts from December, 2020

java chapter11 practice question on abstruct class and interfaces

  /* 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 Writ

java(polymorphisome)

  package com.company ; interface Mycamera { void TakeSnap (); void recordvideo (); //keu use korte prbe na for private,but fayeda hoy //jokhn default method onek boro hoy tokhn private method e rekhe ,private method use korte prbo private void great (){ System . out .println( "good night........" ); } //default method add kora jay jokhn new inrerface er intilize er sathei method declare korar jonno, //jodi pore method declas kora hoy tale r default kaj korbe na default void record4kvideo (){ great(); System . out .println( "recording in 4k......" ); } } interface Mywifi { String [] getNetworks (); void connecttonetwork ( String network); } class Cellphone { void callnumber ( int phonenumber){ System . out .println( "calling..." +phonenumber); } void pickcall (){ System . out .println( "connecting...." ); } } class MYsmartphone extends Cellp

java (default method)(inheritance-interface)

default method   package com.company ; interface mycamera { void TakeSnap (); void recordvideo (); //default method add kora jay jokhn new inrerface er intilize er sathei method declare korar jonno, //jodi pore method declas kora hoy tale r default kaj korbe na default void record4kvideo (){ System . out .println( "recording in 4k......" ); } } interface mywifi { String [] getNetworks (); void connecttonetwork ( String network); } class cellphone { void callnumber ( int phonenumber){ System . out .println( "calling..." +phonenumber); } void pickcall (){ System . out .println( "connecting...." ); } } class mysmartphone extends cellphone implements mywifi , mycamera { public void TakeSnap () { System . out .println( "taking snap" ); } public void record4kvideo () { System . out .println( "taking snap and hd... record video. in 4k.....&

java practical interface

  /* interface ---aker besi impliment kora jay kintu class aktai extend kora jay. abstruct----onek interfaceko aksathe implement kore class bananno jaya also akta class extend kora jay. */ package com.company ; interface Bicycle { int a = 50 ; void applybreak ( int decrement); void speedup ( int increment); } interface HornBicycle { void blowHornk3g (); void blowHornk1g (); } class avoncycle implements Bicycle , HornBicycle { void blowhorn (){ System . out .println( "pee pee poo poo.tujhe dekha to yeah jana sanam" ); } //----------interface method alway public------ public void applybreak ( int decrement){ System . out .println( "apply break" ); } public void speedup ( int increment){ System . out .println( "applyying speedup" ); } public void blowHornk3g (){ System . out .println( "pe pe pe pe kavi khusi khavi gam" ); } public vo

java practice set 10,chapter 10

  package com.company ; class circle { public int radius ; circle (){ System . out .println( "not param of circle" ); } circle ( int r){ System . out .println( "circle parameterized constructor" ); this . radius =r; } public double area (){ return Math . PI * this . radius * this . radius ; } } class cylinder extends circle { public int height ; cylinder ( int r, int h){ super (r); System . out .println( "cylinder parameterized constructor" ); this . height =h; } public double volume (){ return Math . PI * this . radius * this . radius * this . height ; } } class Rectanglee { public int length , breadth ; Rectanglee ( int a, int b){ this . length =a; this . breadth =b; } } class Cuboid extends Rectanglee { public int side ; Cuboid ( int s, int a, int b){ super (a,b); this . side =s; } }

java exercise4

  //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