Sie sind auf Seite 1von 17

~TCONCOMPUTERS

"" \ ;.s- ,- ;$ping w e *


-

Computer Applications

SURA'I.

.Wnat is a class?

1
I A i a s s is a collection of objects with s&~e attributes mcr
,I
operations
- -I
F c ~ e f i n eencapsulation
( Wrapping of data and methods in a single unit is called
1I
encapsulation/
43.Write syntax of creating an object?
Classname object name= new classname();
Eg., icse obj =new icse( );
4.Define module
I
A module is a small program in itself which cm-be tested
I
i
and it can do a specified task.
5.Define an attribute
An attribute is a type of information that a java class
consists. An attribute determines the qualities of the oc.iects I
I
Sdonging to a particdar class.
6.What do you mean by behrrviour of a class
Behavipur can be used to change the attributes of an
objects?
object.Behaviom of a class if objects is implemented using
methods.ail objects can communicate with each other using /
methods.
7.Whgt -are the JDK zpols? -_ _.
. Ja~a-javainterpreter; javac- java compik; javah-it prodticks i
/
header fiiesjdb-java debugger.
I
S.What is the reason of syntax enors in a
Violation of any rule of a programming language causes
program?
] syntax errors.
--,
,$'. Give some situations when syntax error can
I i. wrong use of statement(if-else,for lcop erc.)
!
ii. missing of semi-colon iii.missing of braces
iv. wrong use of punctuation.
.I
is the difference between print( ) and
curcent positioi:
~ h e ~ r i(n) tsends d a b to the n~onl:orat
1
prist'rr~(j ine:hods?give examples.
\ and does nor index to the next line. The prinilno
1
Method terminates tk.e text to--the nex: line autornzticz!;y
-- 1I * . w
I 1 .%'rite four feature of java language.
Java is a plat!orm-independent, it is portzble. ~t is hlgr~y
reliable, ~tis an object oliented language -. ,I
i 12.Vv1itefcur libraries of Java (JDK 1.3).
Jata.iangjava.appletjava.io ,java.aw.
I
u
-wo;menting? /
Comlocnts explnin the purpose of the prosam ard usiiah!~:
!.
/C
used innpai-iicular progranl.
Q
-1 x/-'1~~har is debugging?
The piogamming errors a;e called bugs end the r c m o . . a l d
.
these errors is called debugging. 3ng.- icay occLr dut. to
i
t r
incorrect coding, faults in-design,
cur kz: s m r s
- _ - - _ . . - I - - . - -4
LE='cn
----. . . b-J . ~ l J .
--. , .
?.'ick.;cn ;f =y g:re-r,~.ricd;I :c; rr7.,r.-z. ~ I Y S z i ~" ~ r7
~ .I
r
1 16. Mi'nat do kau mean by runtime errors?
The errors which occurs during the p r v p a i 12:
,,",LC frorr
II
the syntax errors is called runtime errors. Tiles13errf"-s occ.~: I
i
during the program run.eg., dividing a nu.r?;ber ay zeic, z.,
S,-J=Q)
indices out of bounds,range errors.
1- m b ? ; ; (is jc,u mean by logical errors?
When the program doe:; nor produce the cijrr~cto ~ i p ueve
t . ,
if there is no syntax or run time errors.These errors are. m2de

1
1
1

s$
2 -=

F=!S

-------up

?<-.:;.%%

4-3

.,,LLL-".

..L.A

.eusF

pg"s:
k Q- ssb
cr;.go

J?%Z

LA

1.
I

'

Ir--"- - c - -

II l d Liellne a constztr.

--

bT'vJbat is a variable?

1
I

;&I* ::g .
Real cc,ns%mtsare the riambers cor:taiSn;ng S~~?ii;il:!

1 123.34.
/ A variable is a quantity which vancs dur:ng [Lie cxzc~rior.;f
1 a p r o p m , A variable is a memory locr.:icn wC~er:: fri.2
i~"om~srion
is stored.
Boolean, P:reak,defa~lt, swie~h,irn~cfi,:si
I

--

.2$. How uaa YJU &&re ~variabre?


--

!
i

t,r-.fLlrl~4- ...:--I
IL: .,-- Akri.ci!:
::.j36::~:->1:~?

&yL ;:i,e : ..,.,.,.

try.

a flurnbs:.do so: use keyw;rds : r;;i ;


51wk s p ~ c eis allowed behvetn the vhriwizs i.:::~ie, jsva is 2 !
/
case ~er~sitive.
-1
Faecla.iing a vz;;dble is essedia1 bber";>z ssing if ir, 2 J --%va
program. If declaration is not dose,errc(r messeg:: wi!i appcur i
1
Syntax: :mt a;
An opcyarnr is a symbol o i lerter v~Nchcattses L k ciirnpilz: j
3rJc;;::.~?
9;t~.?;I di{fGr.;::.: I
ta!g221; aG;ic,l ilild yield .?
. :.:.a.-..:.>
1;_-._____
dsre ipEJJ;.
,+
li -'.Fz
CalleclWVC.I*II*_L~.
.
.LL_

-r

->

25. Define a.
aope:ator
Lib,y,rtiu;

-a

_ _ _ I _ _ . _ _ _ _

1 First jetter should no? be


(Idsntifierjin java.

Z,-0cL3

-- -- -- - 1
I

I i 9. Vt''n2 are the types of javz constants?

by reai constants?

.b

valu-s wilich abes nor chaz!~:. cj-tri:ig r;.:

-i.-

~ O W
mean

=zzi

.,--

~1

!-&!Y~:;/.LL?~?";;~

.
i

~ ~ ~ :~pii.>i
~ ~ < ' ~ _:
,

Nurture Learning Pvt. Ltd.


-

ITCON COMPUTERS

110-1 15, Citylight Shopping Centre,


Citylight Road, Surat.

Ph. 09377805091

u.

_._
.. .__-_

110-1 15, City tight Shqping Centre,


SURAT. 7

'

de.72+vp

, tr.

%j:$.ff$tr

ITCON COMPUTERS

110-115, City tit Srioppiny Ceilke,


SUhcil.
Computer Applications -2008 b2ch
7. Vf'hat are the types of binary arithmetic

IA

+ ,- , * ,I .% operators

<, <= ,> ,>=, = = and != operators


The / operator firid the quotient whereas % finds the
remainder.
? :is called conditional operator. This stores a value on a
given condition.

28. What are the relational operators?


29. How are the operators / and % are different?

a.

30. What is a conditional operator?

m
p

3 1. What is an assignment operator?

assign Ule value'of a variable,


I
The simple assignment operator assigns its lee operand to its
I right operand.
/ The = assignment operator assigns the value of variables
whereas = = relational operator compares two values.
The comma operator is used to do a left to right evaluation of
an expression. The comma operators does not operate on the
data.
The expression which after conversion (implicit and explicit)
gives a result that has one of the integer ty'pe is called
integral expression.
The expression which after implicit and explicit conversion
gives a result that has one of the floating types is called
floating expression.
The logic operator combine the results of two or more than
two expression connecting og relationship in these
expressions refers as iogic and the expressions are called
Iogicd expression.
It is logical negation. This operator is called logical NQT
operator. If the expression is true ! expression becomes hlse
and vice vex?
I

32. What is simple assignment?

33. What is the difference between = and = =

\ operators?
34. What is the use% comma operator?

35. What is an integral expression?

What is a float expression?

dP

2.gO
+

'E'
Q .z
W E

k i c h a t are logical operaton?


*

I
1
I

logical operator !
-0f ~ O $ S C ~

0~3,~2tot
I!

11

c-,,x,l.
-..Jlllr.-,,c
,

LLYO
e:

A--T

-,LL.-_

. _-

. - -

logical OR operation is false.


[See your textbook for more information ]
&& connects two expression to make them as a single
expression. If both are true ,then the result is true.[See your
etxbtoIn prefix the variable gets incremented first where as in
postfix the variable gets incremented after the operation of
function of its associate operator.
&-bitwise AND, !-bibvise OR, A-bitwiseXOR
- one's compliment, <<- shift left, >> - shift right, >>> shift right with zero fill
The if statement selects one alternative out of he two. It
helps the programmer to test for the condition. It is a
( decision making statement.
I Do
(statements; 1 y~dycinrc ?L

of logical operator &&

increment and pre-increment?

1
1

-.

d .

What does an if statement do?

4 4 Write general syntax ofdo-while loop


45. What is body of a loop?

--.
.

v;
I
>
The set of repetitive statements within aioop is called body
of the loop.

46,What is the difference between do-while and


while loop Do-while
1. The loop executes the statement at least
once when condition is not satisfied.
I
2. The condition is tested after execution
3. If the condition is false, the computer
I . keeps executing the loop
1 47. Define a constructor

1'
1

48. When a constructor is called


49. What is a dk@~$lt
constructor

1 50. Why is a default constructor called so

Mile
1. The statement is not executed when condition is not
satisfied.
2. The condition is tested before execution
3. The loop terminates if the condition becomes false
A constrilctor is a special member function that is
automatically called when an instance(object) of a class is
declared
A constructor is called when an object of the class is created.
A default constructor is a special member function that
initializes the objects.
, It is called default constructor because it declares no

1
I

J ~?&ih"-

OI

Computer Applications -2008 batch


-1 5 :. -bfiat are the characteristics of constructor

ITCON
COMPU-1
tK3
110-115 ~ i iiohf
y Chqping Centres

--

functions
52. What is a parameterized constructor

53. Define an object?


Eg., item, place ,person or any other thing.

54. What are the properties of objects?


5 5.What is a class?

I 56.What are the class members?


57. HOWcan you create objects?

58. What are the ways for passing variables


belween methods?
59.'What is the way of passing arguments?
60. What do you mean by side effect?

Are special member functions and have same name as


class name. it has no return type not even void. It is called
when an obiect of the class is created, constructors are used I
to i*ializeWthe data members of the class.
I Theconstructors which can take different parameters are
/
referred to as parameterized const
An object is a type of data which is a self-contained unit
containing data, codes and the member functions which
operate on data
Identity ,behaviour and state.
A class is a collection of objects. It contains both data
, members and member functions. A class may be defifieed as a
group of objects with same operations and attributes.
Data members, constructors ,member fmctions
At] object can be created using new operator,with the name I
-/ of class.
-..
-I Passing variable by value ,passing variable by address.

9
1
I

Variables referring
- to the obiect are references. Aily chmge

I inside a function is also reflected outside. This proper;^ is

I
called side effect.
Allocating space for a new object. The new operator in jma7\
instantiates a class by allocating memory for a new object. -. i
-.What is nesting of a class?
A class can also be declared in another class. This is called
nesting of class.
63. What is function overloading?
Functions can be created with the same name but different
arguments
/parameters is called function overloading. -- -.
64. Define a slring. How can you obtain the
String is a series of characters. Strings are constant and :C~.ii
length of a string.
values cannot be changed after they are created but string
I
objects can be shared.length( ) is used to find the length.
65.Name the function which changes the case of a toLo..verCase( )
I

I, s!nsg, t"" :e ... . <se.


.
"
"
'
"
'
"
9

-.i

66. HOWcan you create a

----

--

Q,

68. Write characteristics of strings

69.What does charAt ( ) function do?


70.Define encapsulation.

7 1. What is data hiding?

72. What are the types of visibility of class


objects
73. What is scope and visibility of public ?
74.. What is scope and visibility of private ?

q)=

Jzoe

1-

-4

t
Visible to all classes
1
Visible only within the class,not by inheritors, not by other 1
classes in the package.
II
Visible to classes outside the package that inherit the class, 1
I
also to all classes in the package
i
llection of finite number of objects, data

City'llght Woad, Surat.


Ph. 09377805091

.'

76. What is an array?

-in

are mainly created from string literals, when tht


I
S",O
com.y!ier reads a series of characters enclosed in double
-"h
quotes, it inlmediately creates a string object whose vaiue is I j m ~ r n
that which appears between the quotes.
L,
.9"0
String s1="computer",s2="applications"
Z F ~ L
String s3=sl .concat(s2);
~ , o a
A string is a class, string starts with capital letter 'S',
- I
string is a series of characters, In java- e string is not a
character array.
It returns the character at a specified index. An index has the
range from 0 to total length minus 1
Encapsulation means wrapping up of data and functions into /
I
I
a single unit.
Oata hiding prevents the user of an object form being
I
directly accessed by the data members of the class.
i
Public, private and protected visibility

Nurture Learning Pvt. ~ t d .

A=

L . . ~ = C D
(CJ c n w o

75. What is scope and visibility of protected?

.,v,E,

67:u~owcan you concatenate two string?

subscript is the number of elements in the srray surrounded

.,
q

, ,

c t
$

. z-zt:!--;

~t;;,.

-Computer Applications -2008 batch


, 78. Injava, array elements are counted from. ..
i 79. What is a single and dcuble dimension array

1
80. What are the objectives of using arrays?
I

8 1. Flow can you initialize a SDA?

82. What is sorting?

83. What do you qean by linear (sequential)

/ search of an element in an array?


re refer your textbook also.]

I 84. I n a t do you mean by binary search?


I [R.efer your textbook also.]
I

i 85. What is the process of selection sort?

73 2
5.%O

What is t5e technique of bubble sort?


,,\efer :701;r textbook also.]

O5.

s --,

hl

m
s
6 ..c
.E- ~z n= sa~

re;

[$efer your textbook also]

O * O

87. Name the various concepts of OOP.


X8.Eefine thz char data ? y e .

~ 2a , *~ - g
.
i

'$?Pfi
3zzm
+-.pg
L
.

89.Define I!;.= type Boolean

.
90. What is a local variable?
9 1. '??hat is a global variable?
92.What are jump statements(unconditiona1
branch statements)?
93. What is the use of the return statement ?
. What is a scope?

95.What is an Empty loop?


96. What is a time delay loop?
97. What is Infinite loop?
98, What does a break statement do?

---- /'.
Zero
The array whose elements are specified by single subscript
is called SDA. Array having two dimensions is called
DDA.
1.Arrays are used to group storage locations. 2.The
elements which are numerous are declared in a brief marmer
using subscripts, 3 .elements are stored in cofitiguous
locations.
It can be initialized after its declaratior,. Eg., int
6
arr[5]={12,8,20,16,3);
Sorting is a technique in which the array elements are
arranged in a particular order either in ascending or
descending order.
Each and every element of the array is compared one by
one with the given item to be searched. [Refer your
textbook.]
The binary search is an efficient techiq.de to search the
given element in minimum possible comparisons. The
desired element may be present in the first half or the
second half of the may.But elements should be in sorted
order.
Thc smallest element is searched and placed in first
position. after that the smallest element of rest of element is
searched and kept in the 2ndposition and so on.
The first two aajokirrg elements of the array are compared 1
and if found out of order, these elcxent are exchanged
.finaily the elements are manged in ascending or
descending order.
-I
Abstraction, Encapsulation, Inheritance, polymorphisrri
This includes any character belonging to the character setof 1
1 i e i ~ aA
. variable. qiaicih is declared as a char type Secomes a
character
----variable. T1Gs type assumes a size of 2 bytes.
( This iz used to test a particular conditior, during the
exec1 tio on of the program, It takes two values as constants. ,
that i.:true or false. It uses only one bit of storage in the
memory.
aria& declared inside a method or block.
Class variable which is available to the entlre class.
Return, break and continue.

It is used to return
The program area inside which variable can be accessed, is
cdled variable's scope
If a loop does not contain any statement in its loop-body ,it
There is no statements in the body of the loop. It is used to

A break statement terminates the current loop and proyeds


to the first statement that follows that loop.
99. What are the two selection statements in java? If-else and switch-case are the two selection statements.
.1'00. What is statement in java?
Statements are the instructions given to the computer to
perfon11 any kind of action.
101.What is a "fall through"?
When there is no break statement for a case ,then it will
I
execute all the case statements is called fall through.
i 102. Write the difference between switch and if- Refer yuur textbook pg 239.
1 else
103. What are the 3 flow of control construct in a The sequence construct, the selection construct and the
ro ram?
iteration construct.
Is a sequence of characters used in a program to represent a
104. What is a literal?
constant value.
I
i
r
?
i
s
t line of the fimction definition which tells the
program
about the type of the value returned by the
I
function and the number and t-ype of arguments.
Please learn the theory questions from your Textbook also.

L
I

ITCON GoWUTERS

1trj-naqi,iight. S ~ W PCentre;
~~B

Nurture Learning Pvt. ~ t d .

SWt.

110-1 15, Citylight Shopping Centre,


,U

ICSE
V

Citylight Road, Surat.


Ph. 09377805091
I

THEORY +ART 1
I .What is JAVA?
I
i) JAVA is both a programming l a n h e and a platform.
ii) Java can be used to write or create variaus types of computer application3.
iii) Java is also a platform for application development.

iv) Java is a popular third generation programdng hw.mge.


v) It is origindiy named as Oak 1
I
2 . W t is , w A platform?
i) Java is a platform for application development.
ii) Platform refers to combination of hardwart: and system software e.
,- ..L.-:*-- -,
system,+dows NT a d pswer klacs-etc
iii) Java platform is designed to deliver and run highly interactive, d
applications on networked computer system.
,-

3. Explain compilation process. (or)What is compilation?.


The program or code written by a programmer is usually called the source code. This s o m e code
needs to be converted into machine language code, which a computer can 4:asily auldermd. %2
process of converting a soauce code into machine code is called cornpilatio~~.
I

4.What L a translator?
Basically computers can understand only the machine language (0's and 1' 3). Therefore, the
programs written should be converted into machine code. For this, the tmm!ator's soiWme is
developed to convert the languages into machine code. There are 3 types of translator software
available.
i) Assemhher: T i s translator is used to convert the program written in assembly level l m p g e
into machine level language.
ii) Compiler : This is used to convert the high level lmg-nge into machine .eve1language. It
translates a complete program into object code before it is executed. A coml~iledprogram wil rr;r
faster than an intepreted program. Eg., COBOL,FORTRAN ,ADA, ALGOL,SNOBOL z?c.
FA)
pnz""-'c.-r r.:--. 9:..-a -.4 ,. ,,A '.q&
'
'12-.re! ! a n g q e into x:ac?ke !.)i'_;l~l$~.an
GC;U LV UVAA\
interpreter checks for errors statement by statement, convats the statement :nto rnackine code
execute the statement. Eg., GWBASIC, PILOT etc.
L-rluLVI

-;..

Y.L

5. What is JAVA BYTE CODE'?


i) The JAVA BYTiE CODE is a machine instruction for a java processor chip c d b d Java vimd
machine.
ii) The byte code is independent of the computer system it has to run 3~0x1.
iii) Java programs are compiled and their byte codes are produced. The: byte codes are always
exactly the same irrespective of the computer system they are to execute upon.

Nurture Learning Pvt. Ltd.


1"i-115, Citytight Shopping Centre,
Citylight Road, Surat.

Ph. 09377805091

-!

Nurture Learning Pvt. l t d .


110-1 15, Citylight Shopping Centre,
Citysight Road, Surat.

SbFlkl.

Ph. 09377805091
6.What are the chaaactrleristics of JAVA
i) Write snee ran amlaere (WOW)- The Java programs need to be written just once, which
can be run on differentplatform without making changes in the java progml. only thejava
interpreter is changed depending upon the platform.

ii) Light weight code - W~thjava, big and useful applicationscan also be created with very light
code. No huge coding is required.
iii) Security-Java offers many security features to make its program safe md :=cure.
\

iv) Bdt-in Graphics- Java offers many built-in graphics features md routines which can be used
to make java application more visual.
V)

Obj@r%o@ntdLanguage- Java is object-oriented language, thereby, very near to red world.

vi) Sakpposgs MmPBime&a-Java is ideally snited for integration of video, audio, animation and
gaphics in Internet environment.
,-.,
vii) Platform Lndependent- java is essentially platfop independent. Change of plafform does not
&ect the original Java Program/application.
- .

7. Nsme the types of java programs.


There are two types ofjava programs
i) Internet applets- Internet applets are small progams that are embedded in web pages and are
NU on the viewers machine in a secured manner by Java c w b l e browsers.
Applets aae designed to be delivered to Intanet Web browsers and that is v rhy an applet bas .a
bililt-in graphical window. But Java apple&have some security restrictions.
An Internet applet runs within a web browser.
ii) Stand aloae appEirca4ioms- It a soitware application that does not require low level operating
system or hxdwxe access. It could be disdributed on standard IS0 9660 forn.at CD-ROMsand
installed on any Java capable machine. Every stand alone application of S a x '
i.ritl; z s z k ;.eL>od. Zt caa WLIoo m y p:at&ra:

3. What is BBue.T?
i) It is an ewiroment specially designed for teaching at an introductory levc~l.
ii) It was designed and implemented by the Blud team at lbaonash University, Mmblbome,

ArastraEa rand the UPPiversity of sonthem Denmark, Odense.


iii) Blue3 is an g93E (Integrated Development Environment). It irmcludes the GsIlowing tools in ii:
a) an editax ,which you can use to write yow program.
b) R d e b n ~ e rwhich
,
helps you find your mistakes.
c) a viewer, which lets you .we parts of your program graphically.

9. When yoa compile a pmgram written h the Java programming hngatage, the compiles
coxaverts the human readable source Tile into pplrrtfomm independmt code that a .WM can
landemtandl What is this plspl-8orrxn independent code called?
h w e r : Byte code.
10. How can yon say that j a w is both a psugramnning language and a pl~atfom?

Lilce any other pogrmming imguage, We can muse java to write or create v vious types of
computer application. 2% word platform generally is med to refer to some csmb'mation of
Bardware and system software. The java platform is a new softwm platform designed to deliver
and run highly interactivetdynamic and secure applications on networked computer systems.
I I. How is or&hary~ompihtionprocess is StifFerent from jstva compilation?
ordinary compilation ,the source code i s converted to a machine code, ilvhich i s dependent upon
the nutchine or a the platform This resultant machine code is called native emcutable erode?.
Contrary to ordinary compilers, the Java compiler does not produce native e?:ecutable code for a
particular machine. Instead it produces a specid f o m t d l e d Byte code. Tke Java Byte codia
looks a lot like machine language, but unlike machine language Java byte code is e W l y the same
on every platform.

Nurture Learning Pvt. Ltd.


"10-1 4 5, Citylight Shopping Centre,
'itylight Road, Surat.

12. What do you mdewtaad by JVM?


Programs written in Java are compiled into Java Byte code, which is lhen interpreted
Java Interpreter for a specific platform. Actually this Java interpreter is 5novcm as
Virtual Machine (JVM).The machine language for the Java V i m Mack jne is called Java byte
code.The JVM is an abstract machine designed to be implemented on the top of existing
processors. It hides the underlying operating system from Java applicatiorx;.The JVM can be
implemented in software or hardware.
13. W a t is Wdte Once Run anywhere cbracteristies of Java?
P

The Java programs need tb be written just once, which canbe run on different platforms without
making changes in thr.Java program. Only the Java Interpreter is changed depending upon the
platform. This characteristic is known as Write Once Run Anywhere.
14. What js an initial class?
A Java p&gram can contain aany classes. But one class in a Java program can contain the main

method. This class is called initial class.

. .

-. -

--

,A.

15. What k the si@cmce of method mdn?


All java applications begin their execution fkom
java program, then no execution takes place.

method. If no main method is there in a


..

16. Packages in JAVA.


i) javaapplet -java applet package
ii) javaawt - abstract wirmdow toolkit package.
iii) java.io -java input/output package.
iv) java.lang -java language package.
V) java.net -java networking package.
vi) javautil -java utility package.
1'7. What are the JDK tools?
P

Java Development kit provides a number of tools which are essential to develop run$ run Java
programs. The took are:
java
:Java Interpreter. It runs applets and applications.
18vac
:Java co~npiler.It translates Java source codes to byte-code !iles ,so &at Che
interpreter couid read them.
Javadoc
: It creates HTML formats documents from Jcrva source code fibs.
Javah
:It produces header files.
Javap
: it is java diassembler. It encodes byte codes to p r o g m file;;.
Jdb
: Java debugger. Yt firids errors and removes them from the pvgrm.

Nurture Lear;:ing Pvt. Ltd.


110-1 15, Citylight S h ~ p p i n gCentre,
Citylight Road, Swat.

Ph. 09377605091

. ..

i110-1
~15,cCity~iirhtk~ h'o ~~~ i'Centre,
0%$:~$~~
ncj

Nurture Learning Pvt. L"c.


110-115, Citylight Shopping Centre,
Citylight Road, Surat.

SURAT.

Ph. Q9377805091

1. Explain JAVA character set.

i) C h m t e r set is a set of valid charactersthat a language can recognize. ~richaaacder set represents
any letter, digit or my other sign.
ii) Java uses the h i c o d e character set. W,naisode is two-byte character ccde set that has
characters representing almost all characters in almost all human alphabets and writing systems
around the world includeing English, Arabic, Chinese and many more.
iii) The first 128 characters in the Univcode character set are indentical to the common ASCII
character set. The second 128 characters are identical to the upper ????
2. PVh,

T O ~ N SThe
- smallest individual u d t in a programs is h o r n as a TOKEN.
Java has the followringtokens- keywords, Identifiers, LitenL, Pmataa~:omand Ope~abss.

i) XG@pn)rds-are b e words that convey a special m


&
to the language compiter. These are
reserved for special purpose and must not be ?ex3 as n o d identifier names. eg., abstract,
Boolean, default, private, protected, throws, volatile, native, package, cla s, finaslly, interface etc.

ii) Tdeantfiaem - Identifiers are fundamental building blocks of a program and are used an Ga%=
general terminology for the names given to dierent parts of ihe program Ti.
variables ,objects,
dasses, PultpsGons, arrays etc.

zs
Y

*J

:c

a3

66

>

EL .s
'OD%
C C .

-sub-m

0
-4

,=

cn

-40

"x-c;Lg
.
e
a

Identifiers forming m l e of Java state of the following:


a) Identifiers can have alphabets, digits and underscore and doliar s i p characters.
b) They must not be a keyword or Boolean literal or null literal.
c) They must not begin with s digit.
d) They can be of any length.
e) J ~ v is
a case sensitive i.e., upper-case and lower-case letter are txceaed differently.

....>::.-*-

, , ~ --r Ztcrds (cftzzi rekrred to as constants) are data hem that zre Exec3 data values. ; ~ . . r a
allows several kinds of Literals.
a) hteger Literals
b) floating literals
c) Boolecaa literals d) character literal
e) string literals
f ) null Literal.

A s

L~-,$

c
.=3r --.so"

305

aa

Integer :byte ,short, int ,long


979oatbg p ~ b:tfloat and double
a Character :char
* Boolean :boolean

a) Bntntkges Literals: are whole numbers without any fractional part. An integer constant must have

- sign. A
number with no sign is asstuned to be positive. Commas cannot appear it1 an integer constant.
There are 3 types of integer Iliterds - decimal, octal and hexadecima1 Btcmb.

at least one digit and must not contain any dlecimat point. It may contain 3 i k + or

eg., 10, -678,5644

. . ITCON CxMhPUTERS
110-1I 5, o i ijg6
~ ishogph~Centrel

Nurture Learning Pvt. Ltd.

"10-1 -i 5, C i t y l i ~ h tShopping Centre,


SUBAT.
b) Floating Literals (or) red Literal.
C$$&iti.;;d,
:,rat.
A real literal in fractional form must have at least one digit before a aecimal point an
_
1 31
one digit after the decimal point. It may also have either + or - s i p pnxeding it. A R WPT~!
~

with no sign is assumed to be positive.


,
e.,g 2.0, -13.0,-0.00625
A red literal in exponent form has two parts: a mantissa and an expon :nt. The mantissa must
be either an integer or a propet red literal. The mantissa is followed b:r a letter E or e and the
exponent. The exponent must be an intdger.
e.g., 152E05, 152.OEO8,-0.172E-3,152E+8.
1

c) Boolean Literals: It is used to test a particular condition during the e cecution of the prosam.
It takes two values as constants viz. true Or fake. It is denoted by the tern1 Boolean and uses only
I
one'bit of storage in the memory.
I
/
d) ~ h a k c t e Literals:
r
A character literal in javd m ~contain
i
one character and must be enclosed
in single quotation marks. Java allows you to have c d n non-graphic ch,&ers in character
co&ts.%J~n-~ra~hicalcharacters =&those characters $?t c&nG be typed directly from
keyboard. Eg., backspace, mix,"
carriage r e w e t c . These cliiiracters-canI: ii represehfi by using
escape sequences. An escape sequence is represented by a black slash 0) jblIowed by one or more
characters. E.g, \a - Audible bell, \b Backspace, - carriage return etc.

6
0

e) String Literals A string literid is a sequence of zero or more cbara&:rs s - m o d e d by double


quotes. Each character may be represented by an escape sequence.
e.g., "abc" size b bytes (each character takes 2bytes)
'W size 4 bytes@ is one character)
"seemaVs pen" size 22 bytes [ \a and \' are escape sequences 1.

a3

25

==Jw

f ) NuUl Literal- Tbr.null type has one value.

a-s.

3. Concepts of DATA TYPESF


Data types arc meam to identity the type of data an8 associated operat ons oflnandaing it.
Java data types are sf two types:
i) primitive (or) i n h i c data types.
ii) Reference data types.
i) gdanitive

types- It come as a part of the lamguage.Java provides eight pr:&tive

dEit

> CS)
& ."

w
g
c c

.-

C z ?3
? ~m
cs; <a

c3.

Z$%h*
o w
g Ci-D=k
Lt'3

3 M - C $ )

~3 F.ZLs g
0

ZF80,

9
W

ii) Reference dab @pisare cop1shct& fram primitive data types. Thr:se ;ere dasses, mays
and interface.

ITCON COMPUTERS

Nurture Leilrning ~ v t ~. l d .
$Ir;i.

Log%

d.Jj'6.YC1.i
I L?&.a

110-115, city iight Shopping Centre,

Points to remember:
i) All numeric types in Java can store negative as well as positive number,;.
B

ii) By default, Java assumes the hctional numbers to be of double dab type unless specified. To
explicitly specify their type ,use m B e s F and D.

iii) Use suffixes I, L,Uong) f, F7(float)d, D(doub1e) to explicitly specify data type of a data value.

4.Initial values of variables:


Each class variable ,instsince variable ormay components is initialized with a default value when
it is created:
[ Type
1 Initial vdue

5. -%%atis dynamic hitiaKzation?


e.g, short a=O;

short b=a;

Zn which case the return valne determines the initidition This type i r called dynamic
initid izafmn.

6 CPEUTORS EN JAVA
The operations are represented by crperators and the objects of the open tions(s) are ~sfczed
fr, *c
Operands. Izva bas a rich set o f o p m t ~ rcomprises
s
of arithmetic, reHa~oaa4,logical.
52 /. ;.3.--> -v-.~ g d i ~ " 5 (--,
~ k *~ :, - , !, % j
h r i h e t i c operators are binary operator. b'ws it act upon two operands e.g,
r...~r

C=

a +b

a) Unary akiibhetis operatom: - operators that act on one operand are ~eferredto as unary
operators.
i) rm.rrary+ :the operator unary '3-' precedes an op=mnd.
Egl., if a=S +a means 5 E@., if a=O +a means 0 Eg3., if a= -4 +a means -4.

ii) nary :the operator unary '-'precedes an operand.


Egl., if a=5 -a r n e m -5 E@., if a==O+a means 0 E@., if a= -4 +a means 4.
6) Binary ~pemtom:-operators that act upto two operands are refenred tc as binary operations.
i) adation operator (+) ii) subtraction operator (-) iii) multiplicaticn operator (+)
iv) division operator ( / ) v) moddm operator( %).
Operatom + with strings
5 i-6 results into l l
''5" + "6" rcsul@ into :56"
"17" + "A,V,VW' results into "17 A,V,Vbbm7'
"abc" + "123" results into "abc 123"
5+ 'kyz" results into "5 xyz"

Nurture Learning Pv"6 Ltd.


If 0-"i 15, Citylight Shopping Centre,
Citylink-~tRead, Surat.
> t i aSJ/iBC5631

ITCON COMPUTERS
3,o.n5, QQ ugm showins centre*

SURATi
Increment operator apd decrement operators
The prefix increment or demment operators follow changetP1c:m-mede.i.e., they first
change the value of tbeir opemd, then use the new value in evaluation the expressio~~.
Eg., refer your class work
.
* The postfig or decrement operators follow use-then-cha&ge rul: i.e., they fir?i use the
value of their operaud i? evaluation the expression and then chalge the operand's value.
e.g, refer your c h s wofk
I
The increment operator,++and decrement operator - are ohmy o~emtoni.a.,they
operate upon single o e a n d . And the po& incremenffdecremmtoperators I$ve higher
precedence over prefur increment' decrement operators.

I
65) Relational operators: ( k ,<= ,> ,>=, = = ,!=)
I
I
It refers to the relationships1thatvalues can have with one anothet.
Jamprovides six reltional operators for comparing numbers and chiracters. But d e y do not
work with stting.If the comparison is true tlie relational expression n:sults into the value 1 and
if it is false to 0.Avoid equal* comparisons on floating -point a umbers.- -.*.*" .L "
.
0 - - .

6%) Logicall operators: ( & , 1 I ,! )


& - The logicd operator evaluates the resrilting expression as tnu<l) if both the conditions
. are true.
Eg., if (age<=25 && gender = = 'F)

System.out.print("you can join the GSFS sck.001);


else
System.out.printc'you cannot join the GSFS school);

1 ( - This logical operator evaluates to true value if either of the two expressions is me.
Eg., if (clas = = 9 1 1 clas = = 11)
System.out.prinP("you can participate in ZPranatics); ,
else
System.out.print("you cannot paeziciwte in Dramatics);

! ifthe expression is true the NOT operator returns a negative value.

Eg. if( ! (56>90)) result into 1 indicating true as the given er pression being 56 as
greater then 90 is false.
7. Java shodtiP;d operators: Java offers special short-lmdsthat simplify the coding of a certain
i-ype of &?;sigimm:
5bi&n?f:~t.
Egl. x = 10; equivalent to
x=x-10;
Eg2 x * = 3; eqlivaleni to
x= x*3;
Eg3. x 1 = 2; equivalent to
x d ;
Eg4. x % = z; equivalentto
x=x?40z;

*= ,/= ,%= ,+= ,-= are called arithmetic assignment operators.


8. conditional operators ? : It stores a value dependingupon a condition. This is temsq
operatar. i.e., it requires three operands.
Syntax: expressiond? Expression2 :expression3
Egl, result =marla *50 ? 'P' :'F' ;
The identifier result will have value 'P

Eg2., ==(@st

>iecond) ? first :second ;

9.OPEPLQTOIPS:

a) [ I - used to declare arrays. Eg. int [ ] a=r=newint[lO].


t
b) . used to access object of a class (instance members of m object) eg., pl obj%evv PI();
c) ( ) - used when declaring or calling a h c t i o n /ruethod. Eg., smapr a,b);
d) new used to create an array or an object. Eg., refer examples a lurid b.

Nurture Learning Pvl. Lld.


I 'I ,I-" '5, ~ l i v i i q h Shopping
t
Geztre,
C:Ej$cj,~i
1.
Scrat
td
,'..*/
~b91
.+itI

:t

1i

! 6

Cd:)

=a
E
+a w
c
-i a
<.-.J.

Y"

0-

C3

.-a

ITCON COMPUTERS
110-1.15, city tigh<Si~ljogpingcentre,
SURAT.

Nurture Learning Pvt. ~ t d .


17 0-1 15. Gityligl-it S h o p p i ~ yCanti@,
Cityiiyb!l: R33d, Surat.

Ph, o b S ' f ' & ~ ~ y l

10. What is an EXPRESSION?


An expression in Java is any valid combination of operators, constants, ind variables
Eg. s=a+b+cl2 + ,= J are operators ; 2 is a constant and s,a& and c ar: variables.
i) Pare expressions: dl the operands are of the same data type is called pure expressions.
ed expressions.
ii) Mmed expressions: all the operands are ofthe different data type is called

"r"
I

11. Type convvepsiors:

When constants and variables of different types are mixed in an expression, tiey me converted
to the m e type. The process of mnverting one predefined type into mt~tber called W E ,
COTVIERSON. r hmt are two forms of type conversion.

$
I

i) InnpGcit type conversion: An implicit type conversion is a conversion


compiler withod programmer's intervention. An implicit conversion
di&rent&t& types are intennixed in an expression.

;iai.'

ii) Explicit t y p e conversion: An explicit type conversion is user-defineti that force an


expression to be of specific type.

.g:

hA.

i'J

fio&

;6;&de

double L J J

A,,

.+

Wl

I
12. Explain the R E W S statements of JAVA.

i) /*
ii) /!
iii) I**

*I

*/

13. %%atare Assignment operators: These operators aTe used to assign t l ~ evalue of an expression
to a variable. The following are the assignment operators in Java.
Operator
operation
fomnt
Meaning
--Assignment
2-1 0
10 assigned to
The variable a
+=
add to the variable
a+=5
a=a+5
- -subtract fiom variable
a- =5
a=a-5
*=
Multiply to variable
a*=5
a=a* 5
/=
divide into
a/ =5
a=a/5
a%=5
a=a%5
%=
Modulus of
- ,

-.

14. Explain the w e e of Bitwise oyerators in Java.


These operatops act as special ~peratorsfor the manipulation of data at bit level.
Eg., operators
operatoins
&
Bitwise AND

<<

>>

Bitwise OR
Bitwise XOR
left shift
right shift
Bitwise compliment etc.

ITCON COMPUTERS
110.115, city ,Light
Shopping Centre,
I
SURAT.

Fdk;, iure &e~ r rig


i l ' v l , 0,.,%dm
, 116-"i 15, C~'c,yiig;riShcppiric ::ailtse,
lieh!ti E L ~ 2 dC,UM
,

cfL>

15. Name the two control statements of JAVA.


i) selection control statements - IF-ELSE and SWITCH-CASEstatemexits 1
O < ; ~ J t -*c.b;,~gj
ii) Iteration control statements - FOR, W M I L ~D
, O--E
loops statc:ran@nts.p~" bj
i.

16. What is CBM[IPQPSITEDATA TYPES?

The data types that are based on fundamental or PrimitivLdata types ,a:known as
C ( P ~ O 8DATA
I ~ TYPES. All reference data types can be referred tc; as composite data
types. Since these data types are created by users, these are also known as USER-DEF'BmD

DATA TYPES.

17,Types of errom:
rules.
ij Syntax errors: Every language has fixed grammatical rules and are call-d
violation of any grarmmatical rules causes s9tax errors. If the ~rogramlninglanguage is not
band,led properly, syntax errors frequently occur. Syntax errors are also called as
compilation errors. ,
I

E:

.O
8

.,,=-rc-32

0-. ."a.
c

("3

- .- l/s;F;.
c = a

I,s;

IX

L.

Q)

$*,=

2 %- 8

% L n cCC, , L
-3-B
J,

- .

:2

4-

,..;

Syntax error can oc~mkdueto


a) wrong use of statements(if, ifelse etc)
b) missing of semi-colon
c) missing of braces.
d) Wrong use ofpunctuation.
Eg.,Syskm.out.print "A test "; N ( ) is missing is an emor.

zgg
0

ii) Run-tirune errors: A program cannot be successfully compikd if there hppem to be a y


syntax error in the program and as and when this error is removed, the prc gram is compiled. But
couapilatiorr does not mean that the program will produce results or give cutput. There m y be
some other mistakes other than syntax errors which come in the way of e?ccutioa These errors are
called RUN-time errors. common RUN-'IIPI/LE errors are
Dividing a number by zero
b y indices o ~uit bounds
Range error
Other input errors.
18. S~~
VS IF-ELSE
@ switch ceur only tesu for equality whereas if can evaluate a relational or logical eqrerrior
b) ~ w E ~ c & stzts~e1.tse!c~k its brmshes by t e s h g Ihe value of sane vari2Mt. if-^?:.^ !EZ POQ =e
a series of expression that may involve unrelated variables and complex ~xpras.i;oas.
C) ifeke is more kerntile of the two statements. if -else can handle r m p s whereas switch
cannot Each switch case label mus* be a s-mgle value.
d) If-else can h d l e floating-point ,integer md characters. Switch cannot h d l e floattiag-point
data type.

19. JUMP statements:


Java has three statements that perform an unwnditiona! branch.
return, break and canbinue. [ Refer textbook to learn more about jump %%ternmts.1
20. Define constants.
A constant is s fixed value which does not change during the execution of a program.

Nurture Learning Pvt. Ltd.


110-1 15, Citylight Shopping Centre,
Citylight Road, Surat.

FJnjr;k*pc:

h-es~rring

\-jwt,,

I-td.

I 1 0-? 15, Ciivlly 17 Si\r9g!ping Centre,


C:iIy:igi4"ia';~;id, ,46ir~:i"

lTCON COMPUTERS

110-115, Cifiight S h ~ ~ i Centfa*


ng
SURAT.

Pia. c93T7$(j$fi21
BRY PART E
l
1. Define the tenn Object Oriented Programming.

OOP stands for Object Oriented Programming. The programming languages Ctl- ssnd Java
follow the 0 0 F concepts. The limitations of the procedure oriented programming (POP)
~ ~ g ehave
s given
,
place to the dwelopment of the OO?. The different OO? languages are
C*, Java, small^, Sizaula, Eiffel etc.
2. How does an Object differ fiom a class?
Object: An object is an identifiable entity with some characteristic and behavior.
Eg., refer your Xerox copy notes.
Chss: A class is a group of object that s h e common properties and relationships.
3.%a," the various conbcpe of Object Oriented Programming.
3211: basic concepts of OOP are:
i) Abstraction
ii)Encapsulation
iii) Inheribam

iv) Polymorphism

b u :

i)Abs.BPras~orm-refers to the act of representing essential features withcut including ahe


-bac&ound details or explanations.

-.

ii) Enclapasalationa- is an act of wrapping up of data and methods~~ctions)


into a single mit is
cded encapsulation. It is one of the most fundamental concepts of the OOP: The very h d d o n
of the data from direct access by the p r o w is termed as Data Hinding Encapsulation ,is hence
just a way to implement Abstraction.

iii) Hwheritomee- is the by which objects of one class acquire &e p p r i e s of objects of mothex
class. This further provides an irnpommt extension to the idea of reusani1ity.e.. a part.ia~Je:
prapmmex can make use of an misting class and without my fiarher ~nodificatiori~,
add
additional f e m e s and capabiliths to it, by deriving a new class from tk.e existing one, though
irlhe~tan*.
iv] ira@m:ngb&m is the :ap,ciw $9bllow ~);tjw.t~
~E.--~TA;i.Tw-~+
hf3~:'?:
Cti
- +----.
J M L ~ C xtmai intdaw. It is the ability jbr a messrage or data to be proaased in mme urn axle
rhrt..~ v +

fom.
4. Name any fom advannntages of OOPS.
i) Elimination of redundant coding system and usage of existing classet through inheritance.
ii) Program can be developcc! by sharing existing moddes.
iii) Secrarity of data values from other segments of the program through data hiding.
iy) Possibility of co-existence of multip1e instances of an object without any interfereme.
5 . CL4S8%S

OBJECTS:

a) A java prop;rm consists of objects and object is referred ta as an instance o f the dass.

b) W 3 . e ~a class is ddmed, m m.emory space is allotted to it. This is becaw a class is simply a
blue print or logical placeholder containing objects and methods. Memory space is allocated when
objects ofa class type are mated.
c) To declare variables that are members of a class, the declarations must be within the class body,
but rtot witbin the body of a fimctionlm&od. Variables declared within the body of a method are
focd to &at method,
..

$1class variables are of two types


i) c k s vrsriabi~(staticvariable) : A data member that is declared once for a class. All objects of
the c h s type, share these data members, as there is single copy of them available in memory.
ii) Iw4ance variable: A data member that is created for every object of the class is called
instance variable.

ITCON COMPUTERSNurture hezii.:ing $Y! ;Sd*


I I r 0-115, ~if.y'Cight%happingCentre.
"1 10- 11 5, C,iy:igl-!GSh[)ppiiid i. u;~li'@,
SdSkT.

CityiEgt!! Road, Suraa".


6.Java provides four BCCES$ NIoDXHERs:
a) public - access by any other c h s anywhere.
Ph. k.833 1805091
b) protected -accessible by the package classes and any subclass that ar{ in other pac ages.
c) Default - accessible to classes in the same package but not by classes in
other
packages, even if
I
I
these are subclasses.
d) Plivafe -accessible only within the class. dven fimctions in subc11asse:; the same packagedo
not have access.
I
1
1
7. Define a module.
I
A module is small prbgi-a& in itself -.~ldch?=,be tested and it can do i specified task.
I

8. Define an attribute.
I
An attribute is a type of information that a java class consists. An atrriitute &tennines the
qualitie,wf,theobjects belonging to a particular class.

9. What is data Ihidimg?


hiding prevents the user of an objec~
from,bein@irectly accessed by thedata members of
the C~WS.

'

10. What are the types of visibility of class objects?


public ,private and protected visibility.

11. What do you mean by public private and protected visibility?


i) pubbc visibiity: is one of the most important access specifier injava programming.
When the base class is publicly inherited, the public members of the base class become public
member ofthe derived class.
In public inheritance the following rules should be remembered yon.
a) each protected member of the base dass is protected in the derived class.
b) each public member of the base class is public in the derived class.
C) each private merr,ba of the base class is private in the derived class.
ii) private visibility means that the base class has been inherited privately.
a) public members of the base class are private in the derived class.
b) Protected members of the base class a e private in the derived c1z.s.
c) private aernbers of the base class are private in the derived clszs. Th.237 arc only visible in
tlx base c1:rss.
it is to & nosd that m e ~ b e r so
s inherited in the de~ivedclass can be accessed only tluough
member functions of the derived class. Further if the derived class is Ihe h e class of my
other class, these inherited members cannot be M e r inherited.

iii) Protected visibility means the derived class can access private public members of the base
class protected. In protected inheritance, the foIIowing rules should la followed.
a) Protected members of the base class are protected in the derived r :lass.
b) Public members of the base class are protected in She derived elacs.
C) Private members of the base class remains private. They are visible only in the base class.

Nurture Learf~ingPvt. ktd,


110-1 15, Citylight Shopping Centbre,
Citylight Road, Surat.

Ph. 0937780509'1

fir\-,.

. i i

C~N@UTERS

v
nur,aKklid;rt$
iLe&r;-li~g
Pv;. $%d,
i9 0-1 15, Gily!igi~lShop:lng Centre,
Gitl;iiyhk L x d , S ~ r a r .

PI!. -

'

110.115, City iight Shopping Centre*


SURAT.
TIPJEORY PART Ta7

i~i
'"))5O"'"
r 43 i

~J~JLJ.

i) A complex problem may be decomposed into a


called functions.
ii) A function contains a set of statements which can bbz invoked frsm sly part ~f the program.
iii) A Laction is called or invoked as many times as it is required.
iv) F o m l parameters- the parameters or arguments declared in the firaction definition are called
f m d parameters.
v) actual parameters- the parameters or arguments that appear in fianction d l statemeat ate called
actual parameters.
Eg.,
class pl
i ;.
/I
function definition
s@bEc int icse (int x, int y)

.-.

~ t u x l x";
1

Public static void main(tring nQ throws IOEpception)


{ int a=IO,b=5;
int c=icse (a,b); // calling a function or invoking a function.

11

Here a and lia are acctual parametem. x and y are formal parameters.
2. Why FTJNCTXONS?
i)
to allow us to cope with complex problems.
ii) to hide low-level dztails that otherwise obscure and confuse.

iii) to reTse portions of code.


iv) a fimctim can retux only one value at a time.
3. what is FUNCTION PROTOTYPE m d SXGNA'ITJRE?
A PnTCDOW PROTCPTBITbE is the fkst fine of the h c t i c n defition that tells &C T ; G ~ ~
a%ovt6:";
oft h , ~~ 2 1 rctui3~G.F~
~ 3
t ! fur
~ ?don and %kci ? , r i ~ $ x rt t.6 ~rpc,~r"?~:~%~::a%.
Zg., ;a.
:isscLOOS(hta.ht b)
R
A FUPTCljlaOH SIIGNAT
refers to the number aed the data tylpes orthe ,xgtunenbs in the
function.

4.PASS BY VALWE (CALL BY TbfiUE) in functions.


M n g call by value, any change in the formal parameter is not reflected back to actual
parameter.
PASS BY mETEEmMCES:any c h g e in the values gets reflected to th= data.

In &war, an primitive types art: passed by vdae and alg xeferemce typc:s (objects, arrays) are
passed by rekemse.
FUNCTQNS: A pwe h s t i o n is one that takes objects or prinli'rives as arguments but
does not modify the objects. The return value of a pure function is either a primitive ar a new

object created insick the function.


M P U W BVNC'FBNS : It changes or modifies the state of received object.
6 . Whart is frgn&oa overkocaadhg?

i\

F u i l d ~ ioverloadiig
l
is the methods for calling several Pma$oms bgre f he sams name. These
functions are different by the number of arguments arid the .data types of the agumcnts passed to
these fihnctions.
Eg., float area (float radius) N 1 atgumat with float data type
float area(float length, float breadth) // 2 arguments with 2 float data types.
float aregfloat side1$oat side2,float side3) // 3 arguments with 3 Roat data types.

Nurture Learning Pvt. Ll-cl.


1%
8-1 15, City!;

+:'

Shopping Cz.!??"?,

Citylight Road, td !:'at.

$ha Q93778G5C4";

r'

ITCON COMPUTERS

110-115, City Light Silopping Centre,

SURAT.
7. What is a @ON$TWUCTOlt?
is called fCQNsTRUcrQF
il A member h c t i o n with the same name 2151 its
initialize the objects of that class type with a legal kitidvalue.
ii) Constructors have no return type, not even void
iii) Constructors get executed amtommoticd'ywhenever an object is cre3eed for the cl85:ss.
J.- UGtOn;
iv) default constnnstora :A constructor with no parametem is called s default conp*
V)~wametarizedsonstrmstors: constmct~)rs
which have arguments tiefined in t1:eir panthesis
&e called parameterized constructors.
8. What is an ARRAY?
i) An array is a collection of variables of the same data type that are re Ferenced by a common

l-&Ae.
ii) Array consists of contiguous memory locations. Tke lowest address r:oneqmnds to the Tist
clemefltand the highest address to the last ebmeui.
iii) T k element numbers in [ I we called subscripts or indisee. AJI m
s y must be defied before it
can be used to store information.
Iv)
Thc data t j p e of m y elements is known as the bm,type of the m i y .
V) two types of m y s : single or one dimension array and double or two dimension may.
v) Tne subscripts other than 0 to n-1 far inn m y having n elements art: called out-af-bounds
sublbscrige~.
9. what is $ORX'ING
?
Sorting of an array is the technique of arranging the array elements in a spc%ed order. i.e. either

in ascending or descending order. The two types of sorting are


i) BUBBLE SORTING IN bubble sort, each element is compared with its adjacent element. If
the first element is larger than the second one then the positions of the elements are interchanpecl,
otP-~miseit is not changed. Then next element is compared with its adjiicent elexnetit md the same
process is repeated for all the eiements in the m y .
ii) SELECZXn"OhTSORTNG- The selection sort techoique is based upoz~the exkrisiar?of h e
maximud miuimwn technique. By means of a nest of for loops, a pass through the array is made
to locate the m i a u m value. Once this is found, it is placed in the &st position of the array.
Another pass through the remaining elements is made to find the next s~ndlcsteiernc~t,which is
placed in the scc~ndposition and so on.
10. w h t is YE&P.irrIIPI"JG UP ARK4.Y EL&+M.ENr?
Searching is used to find th$jocation where eimefit i s available or not. There are: two types.

i) LmAX SEARCmG-In b e a r search, we access each dement of an array oae by ow


sequentially an6 see whether it is the desired element ~r not. A search will be w t ~ c e s s f uilf dl
the elements are accessed and the desired element is not found.

ii)BHNARY SEARCHING- Binary search is an extremely efficient. This search technique


searches the given item in minimumpossible compariso~.To do the b i m y search, f h t we had to
sort the array dements. Follow the steps.
a) first find the middle element of the m y .
b) Compare the mid element with an item
C) There are three cases
if it is a desired element then search is successhI.
i)
If it is less than desired item then search only the fmt hdf o:Tthe may.
ii)
iii)
If it is greater than the desired dement seme11in the second 11df of the may.
Repeat the same steps until an element is found in the search area.
4,

Nurture Learr?iirg Pvt. Ltd.


110-1'1 5, Citylight Shopping Centre,
Cityligllb Road, Surat.
Ph. 893776135891

13
-___2__._I

Das könnte Ihnen auch gefallen