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

a program.

process/execution stages in Java.


compilation
2. Explain the both
Stages in Java. Java programs are
d compiled and interpreted
interprete
level 1language
Process/Execution
IS. Compilation cource
the code to
to an intermediate level
source code an
called
compiler
The Java compie
translates
which
T
the program is run. The same bytecode.
independent of the machine on
bytecode file can be
It is
used by any system. its bytecode
an another
written on system,
another system,
bytecode needs to be transferred to
na

To run a java program


program
Machine. JVM
is interpreter
is an interpreter
translateo
which transiates the its own
program to its own machine
Java Virtual result.
to give the
language and r u n s it

Introduction to Object Oriented


Programming Concepts Sza
For Macintosh OS
Java
Java
For Windows -XP OS
Java Progran Java Compiler Bytecode
Interpretecr
Programn For UNIX OS
Beutian stanme of Inun hutecode
(35. What are the different types of Java programs? Briefly state each of its application area.
Ans. Diferent types of Java programs and its application areas:
(a) Stand Alone Application Programs: An application program reads from and rites to the
files only on local computer.

(6) Applets: These are the Java programs that are executed in a web browser like Microsoft
Internet Explorer: They can only access the resources of a remote system.

(c) Servlets: They extend the functionality of web servers.


(d) Packages: A package is a set of a number of classes.
SOLVED QUESTIONS
SectlonA
Short Anwwer Typu veatlonn)
1) Defne: (a) Attribute (b) tehavlour (e) Methol. be the structure, nume,
the objectn ln n elass, Iu
cnn
Ais. Atribute. An attribute is a datn viulue held by anl weight ure the nttributes of
nume, uge, helght
olher ehuracteristies of an obfect. e.g.,
S1Ze and
the olbjects of the class perxo.
Behavlour. It is an netion thut nn objectl perfornis. mehoxd,
by certnin cluss is called
Method. A specific implementation of
n operntlon a

What docs nn objeet transfer to the


other?
2.

Ans. object transfers messange to another olijeet.


An
an olject.
3. Diferentinte hetween a cluss und
Ohject
Class clas.
instunce ofn
from wlhiclh Objecl is nn

Ans. Class is a blueprint or template


objects arc created.
existence
Objeet hns plysical
Class has logical existence. allucnted,
space is
allocutcd, wlhen I n case ofun object memory
For class, memory space isnot when it is ereated.
it is created. timcs.
Object is created many
Class is declared once.
keyword new'.
declared using the keyword
'class'. Object is crented through the
Class is

How c a n an object entity and its behaviour?


model an
4.
refers to developing or giving shape.
a
Ans. Modelling: Modeling
has a body.
refers to anything that
Entity: An entity
An action that an entity performs
is called operation.
an
Behaviour/Operations:
data structure and its behaviour in a single entity.
used to describe the
Object: It is a term

called an object factory? can be culled as a factory


5. Why is a class of fndividual objects. So, it
Ans.
infinite
Each class describes possibly an of
set can lhave numerous objects
as Nokia, Sumsung,
a cluss cellphone within the class.
of objects. For example, of the objects are described
and functions
Panasonic, etc. The features methods of object.
thhe Comment.
the attributes and t
unit. It makes the
makes the
6. Encapsulation wraps up object into an a single unit.
the attributes and methods of
Ans. Encapsulation wraps up from misused.
them snte boing
independent and keeps
classes
maintuin its ldentity?
7. How does an object are distinct even
if they have same
own identity. It
m e a n s that two objects are the
Ans. An object has its Maruti's are plysicully distinet though they
e-g, (wo
name und size).
attributes (structure,
Marutl.
objccts, 1.e.,,
same stato nnd behvlour
examples to show that objects encapsulute charneteristics of memory
Write two cellphone hus its
own attributes like
a Samsung size and shape.
lt also has
As. Every object has its minimum tone, volune, its
tones, maximum and Thus, its stute
(nltributcs)
(size), number of ring like send und receive calls, games, ctc.
its own behaviour(functions)
bound in one unit thut is "Object".
and the behaviour is Classes t t
Concept ofObjects and
Elementary

Scanned by CamScanner
9. What does a class need to define, when used as a data type in a Java project?
values and functions or methods that
Ans. A class needs to define data variables to store the data
variables are called
define the process to be performed on the objects of the class. These data
member variables and the methods are called member functions or member methods.
10. How does a class implenment data abstraction and encapsulation features of OOP?
Ans. A class defines the data variables (called member variables) and the methods/functions (callcd
member functions) common to a set of objects of the class. In other words we can say that these
members varíables and functions are encapsulated into a single unit called class. This encapsulation
leads to abstraction (hiding). Due to this encapsulation, users know how to access the encapsulated
code no matter what the implementation details are.
11. Is it possible that an object has more than one abstractions? Explain with examples.
Ans. Yes, it is possible for an object to have more than one abstraction. This can be understood from an
example of an employee. The attributes and methods for the personal details of an employec can
be wrapped up in a class named "Personal" and the attributes and methods related to details of
the employees salary can be wrapped up in another class named
"PaySlip". Thus, the
same
can possess multiple abstractions by encapsulating relative attributes and methods in more than
object
one classes. Similarly, an account holder can have the personal details in one class say-AccHolder
nd the details of the account in another class say-AccBalance.
12. How to create an object in Java?
Ans. An object is created from a class. In Java, the new key word is used to create new object.
For example: progl objl= new prog1()
Where progl is the class, objl is the newly created object's name and prog1() is the constructor
of the class.
13 What declarations are required for every Java application?
Ans. A class and the main()
method declarations.
aWhy object is called an instance
an
of a
class?
2010
Ans. A class encapsulates the data members and member functions. It is used to create an object. A
class is an object factory. Hence, an object is called an instance of a class.
I5.) Why is a class known as composite data type?
Ans. Class is called a composite data type because it binds
types together as a single data type.
up (encapsulates) one or more primitive
e.g, class Abc {
int x,
float y;

16. What does the following mean?


Employee staff=new Employee0;
Ans. The statement Employee staff = new
Employee( ) creates an object named staff of the class
Employee. It also allocates memory to the object.
17. How is a class type variable declared?
Ans. Declaration or creation of class
type variable (object).
18. What is this
Ans. The class
class type variable called?
type variable is called object of the class.
397gethesecek Computer Applications (ICSE)-9
Scanned by CamScanner

You might also like