unit 1 java programmin second part

Post on 06-Apr-2017

27 Views

Category:

Education

3 Downloads

Preview:

Click to see full reader

TRANSCRIPT

SMT. K K PATEL MBA / MCA COLLEGE

PINKESH MODI (MCA) PAGE NO : 1

Que 1 : What is a Classes?

A: classes are group of data member and member function.

Syntax :

Class classname // instance class (local – class)

{

Field Declaration ; // instance variable declaration

Methods Declaration; // instance methods declaration

}

Class classname

{

Public static void main(String s[ ])

{

Body of the code;

}

}

SMT. K K PATEL MBA / MCA COLLEGE

PINKESH MODI (MCA) PAGE NO : 2

Que 2: What is a Instance Variable?

A: Instance variables are variables within a class but outside any method. These variables are instantiated when the class is loaded.

Syntax :

Class classname

{

Field Declaration ; // instance variable declaration

Methods Declaration; // instance methods declaration

}

Que 3: What is Class Variable?

A: These variables are declared with in a class, outside any method, with the static keyword.

Que 4: What is Local Variable?

A: Variables defined inside methods, constructors or blocks are called local variables. The variable will be declared and initialized within the method and it will be destroyed when the method has completed.

Que 5: What is Object?

A: An object is runtime entity of the real world.

An object in java are create using the ‘ new ‘ operator.

Syntax :

Classname objectname = new classname( );

SMT. K K PATEL MBA / MCA COLLEGE

PINKESH MODI (MCA) PAGE NO : 3

SMT. K K PATEL MBA / MCA COLLEGE

PINKESH MODI (MCA) PAGE NO : 4

SMT. K K PATEL MBA / MCA COLLEGE

PINKESH MODI (MCA) PAGE NO : 5

SMT. K K PATEL MBA / MCA COLLEGE

PINKESH MODI (MCA) PAGE NO : 6

SMT. K K PATEL MBA / MCA COLLEGE

PINKESH MODI (MCA) PAGE NO : 7

SMT. K K PATEL MBA / MCA COLLEGE

PINKESH MODI (MCA) PAGE NO : 8

SMT. K K PATEL MBA / MCA COLLEGE

PINKESH MODI (MCA) PAGE NO : 9

SMT. K K PATEL MBA / MCA COLLEGE

PINKESH MODI (MCA) PAGE NO : 10

SMT. K K PATEL MBA / MCA COLLEGE

PINKESH MODI (MCA) PAGE NO : 11

SMT. K K PATEL MBA / MCA COLLEGE

PINKESH MODI (MCA) PAGE NO : 12

} }

SMT. K K PATEL MBA / MCA COLLEGE

PINKESH MODI (MCA) PAGE NO : 13

SMT. K K PATEL MBA / MCA COLLEGE

PINKESH MODI (MCA) PAGE NO : 14

SMT. K K PATEL MBA / MCA COLLEGE

PINKESH MODI (MCA) PAGE NO : 15

SMT. K K PATEL MBA / MCA COLLEGE

PINKESH MODI (MCA) PAGE NO : 16

SMT. K K PATEL MBA / MCA COLLEGE

PINKESH MODI (MCA) PAGE NO : 17

SMT. K K PATEL MBA / MCA COLLEGE

PINKESH MODI (MCA) PAGE NO : 18

SMT. K K PATEL MBA / MCA COLLEGE

PINKESH MODI (MCA) PAGE NO : 19

SMT. K K PATEL MBA / MCA COLLEGE

PINKESH MODI (MCA) PAGE NO : 20

SMT. K K PATEL MBA / MCA COLLEGE

PINKESH MODI (MCA) PAGE NO : 21

SMT. K K PATEL MBA / MCA COLLEGE

PINKESH MODI (MCA) PAGE NO : 22

SMT. K K PATEL MBA / MCA COLLEGE

PINKESH MODI (MCA) PAGE NO : 23

SMT. K K PATEL MBA / MCA COLLEGE

PINKESH MODI (MCA) PAGE NO : 24

SMT. K K PATEL MBA / MCA COLLEGE

PINKESH MODI (MCA) PAGE NO : 25

SMT. K K PATEL MBA / MCA COLLEGE

PINKESH MODI (MCA) PAGE NO : 26

SMT. K K PATEL MBA / MCA COLLEGE

PINKESH MODI (MCA) PAGE NO : 27

SMT. K K PATEL MBA / MCA COLLEGE

PINKESH MODI (MCA) PAGE NO : 28

SMT. K K PATEL MBA / MCA COLLEGE

PINKESH MODI (MCA) PAGE NO : 29

SMT. K K PATEL MBA / MCA COLLEGE

PINKESH MODI (MCA) PAGE NO : 30

SMT. K K PATEL MBA / MCA COLLEGE

PINKESH MODI (MCA) PAGE NO : 31

SMT. K K PATEL MBA / MCA COLLEGE

PINKESH MODI (MCA) PAGE NO : 32

SMT. K K PATEL MBA / MCA COLLEGE

PINKESH MODI (MCA) PAGE NO : 33

SMT. K K PATEL MBA / MCA COLLEGE

PINKESH MODI (MCA) PAGE NO : 34

SMT. K K PATEL MBA / MCA COLLEGE

PINKESH MODI (MCA) PAGE NO : 35

SMT. K K PATEL MBA / MCA COLLEGE

PINKESH MODI (MCA) PAGE NO : 36

SMT. K K PATEL MBA / MCA COLLEGE

PINKESH MODI (MCA) PAGE NO : 37

SMT. K K PATEL MBA / MCA COLLEGE

PINKESH MODI (MCA) PAGE NO : 38

SMT. K K PATEL MBA / MCA COLLEGE

PINKESH MODI (MCA) PAGE NO : 39

SMT. K K PATEL MBA / MCA COLLEGE

PINKESH MODI (MCA) PAGE NO : 40

SMT. K K PATEL MBA / MCA COLLEGE

PINKESH MODI (MCA) PAGE NO : 41

Fill in the blanks in each of the following statements: a) Lists and tables of values can be stored in . ANS: arrays. b) The elements of an array are related by the fact that they normally have the same . ANS: type. [Note: In the book, the answer is incorrectly stated to be “name.”] c) The number used to refer to a particular element of an array is called its . ANS: subscript. d) The process of putting the elements of an array in order is called the array. ANS: sorting. e) Determining whether an array contains a certain key value is called the array. ANS: searching. f) An array that uses two subscripts is referred to as a(n) array. ANS: two-dimensional. 10.2 State whether each of the following is true or false. If false, explain why. a) An array can store many different types of values. ANS: True. b) An array subscript should normally be a floating-point value. ANS: False. An array subscript must be an integer or an integer expression. c) An individual array element that is passed to a function and modified in it will contain the modified value when the called function completes execution. ANS: False. Individual primitive-data-type elements are passed by value. If a reference to an array is passed, then modifications to the elements of the array are reflected in the

SMT. K K PATEL MBA / MCA COLLEGE

PINKESH MODI (MCA) PAGE NO : 42

original element of the array. Also, an individual element of an object type passed to a function is passed by reference, and changes to the object will be reflected in the original array element.

top related