Untitled Notebook

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

ADT

Mrymk
1)Adt = abstract data type .is an abstraction of data structure which provides
only interface(‫ )واجهة‬to which data structure must adhere (‫)التمسك‬to.the
interface doesn’t give any specific details about how something should be
implemented(‫)تنفيذ‬.

2)Data structure = is a way of organizing data so it can be used easily ,they


are important because they make code easier to understand.

< Interface only shows


3)question for interface headings they are considered
abstract methods

Public interface ATM{


Boolean verifyPIN(string pin);
String selectAccount();
Boolean withdraw(string account ,double
amount);
Void display(string account,double
amount,Boolean success);
Void showbalance (string account);

4)the implements clause=for a class to implement an interface it must


end with implement clause.
5)Inheritance=extension of existing class.
Security
Public camera extends security{
active
}
activate

&
active

active

active

Super class Mammal has only one method


drinkmothersmilk();

Sub class Human has two method


drinkmothersmilk(); and
thinkcreatively();

6)polymorphism = poly means many and more means one or more,


polymorphism is ability of an entity to take several forms.

Example
Java identifies type of
the computer as
notebook and calls the
tostring() method
Business
associated with
man
notebook

The same person is playing


different roles at the same
sitituation this is called
polymorphism .
8)abstract class(concrete class)=can’t be instantiated(‫ )ال يمكن انشاء مثيل له‬,it
may declare abstract methods.methods of interface is called abstract method.

Abstract class can have


2 t
Abstract Concerete Data fields Constructors
methods methods
with
no
body
body

9)wrapper class=used to store a primitive type value in an object type.

↓ ↓ ↓ ↓
Byle Double Integer Short

10)java interface can declare method but can’t implement them.


11)class vs interface
↓ N
Can extend 0 or Can’t extend class
1 class
Both can implement 0 more interfaces
12)class object= every class has object as superclass,all classes
inherit the methods of objects but may override them.

13)method tostring =always override to string method if you want to


print object and object.tostring return string.

14)example

Object athing= new Integer(25); //program

eger

athing=

Value = 25

athing.toString(); V
athing.intValue(); x
15)why does the following a syntax error:

Integer aNum = aThing; Because incompatible types.

14)overloading= having methods in class hierarchy which have


same name,return type.but different parameter.
15)typecasting= deals with the conversion of one data to another data
type implicitly or explicitly.
&
2 types of typecasting


Upcasting Downcasting
· Can be done implicitly· be implicit
Can't

& ex.overridden methods


·typecasting parent
be accessed
can
object child
to
object
·typecasting child

to
object parentobject

16)overriding= having methods in class hierarchy which have same


name,return type,parameter.

17) fill in the blanks


implements
—————Used to inheriting interface a by class b.
extends
—————Used to inheriting class a by class b.

You might also like