What Is Object-Oriented Programming? How Is It Ans
What Is Object-Oriented Programming? How Is It Ans
How is it
different from the procedure-oriented programming?
Ans.
Ans.
Ans.
byte b,c;
b =2;
c = -114;
k = 2;
For example,
int x = 10;
int j = 98;
For example,
long ds = 1000;
long se;
se =ds * 24 * 60 * 60;
For example,
double P, R;
P = 10.8;
R =3.14215;
For example,
float x;
x = -1111;
For example,
Int score;
Score=90;
For example,
char c1,c2;
c1 =84;
c2 ='g';
For example,
boolean flag;
flag= false;
Ans.
Examples:
int m = 50;
byte n = (byte)m;
Ans.
Ans.
Ans.
Variables
Variables are the data types that store data items
that typically differentiate one object of the class
from another. They are also referred to as data
members of a class. Every class you write in Java is
generally made up of two components: attributes
and behavior. Let's consider an object to define a
motorcycle. Attributes are the individual things that
differentiate one object from another and determine
the state, appearance, or other qualities of that
object. The attributes of our motorcycle might
include:
1color: red, green, silver, brown.
2make: Honda, BMW, Bultaco.
3engineOn: true, false.
Attributes are defined by variables, in fact, you can
consider them because each instance of a class can
have different values for its variables, each variable
is called an instance variable.
Methods
These define the operations you can perform for the
class--so they determine what you can do to, or with,
objects of the class. Methods typically operate on the
fields--the variables of the class. A class's behavior
determines what instances of that class do when
asked to by another class or object. Behavior is the
only way that objects can have anything done to
them. Our motorcycle class might well have the
following behavior:
Speed up
Change gear
Ans.
Ans.
Ans.
Ans.
Ans.
Ans.