0% found this document useful (0 votes)
4 views6 pages

Jav 1

Uploaded by

MONICA NAHAK
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views6 pages

Jav 1

Uploaded by

MONICA NAHAK
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Dt : 19/7/2023

faq:

define "Object"?

=>"Object" is a Storage related to a class holding the members of Class.

=>we use "new" keyword in Java to create "Objects".

ii
syntax of Object Creation:

ath
Class_name obj_name = new Class_name();

==================================================================

aip
(a)Classes in Java:

=>Class in Java is a "Structured Layout" generating "Objects".


hM
=>Class is collection of Variables,Methods,blocks,Constructors and main().

=>Classes in Java are categorized into two types:

1.Pre-defined classes
tes

2.User defined classes


a
nk

1.Pre-defined classes:

=>The classes which are ready constructed and available from JavaLib are
Ve

known as Pre-defined classes or Built-in classes.

Ex:

String

System
2.User defined classes:

=>The classes which are defined by the programmer are known as User

defined classes.

Ex:

Display

ii
Addition

ath
DataTypes

===================================================================
===

*imp

Variables in Java:
aip
hM
=>Variables are the data holders in the programs.

=>Based on datatypes,the variables in Java are categorized into two types:


tes

1.Primitive datatype variables

2.NonPrimitive datatype variables


a
nk

1.Primitive datatype variables:


Ve

=>The variables which are declared with primitive datatypes like byte,

short,int,long,float,double,char,boolean are known as Primitive datatype

variables.

=>These Primitive datatype variables will hold "values".


2.NonPrimitive datatype variables:

=>The variables which are declared with NonPrimitive datatypes like Class,

Interface,Array,Enum are known as NonPrimitive datatype variables or

Referential datatype variables.

=>These NonPrimitive datatype variables will hold "object references"

ii
===================================================================

ath
===

*imp

"static" keyword in Java:

aip
=>"static" keyword in Java "will specify the location of Programming

Component memory" in Class or Object.


hM
=>static programming components will get the memory within the class.

=>NonStatic programming components will get the memory within the Object.
tes

===================================================================
=======
a

*imp
nk

=>Based on "static" keyword the variables in Java are categorized into two

type:
Ve

1.static variables

2.NonStatic variables

1.static variables:
=>The variables which are declared with "static" keyword are known as

Static variables or Class Variables.

=>These static variables will get the memory within the class while class

loading and can be accessed with class_name.

ii
2.NonStatic variables:

ath
=>The variables which are declared without static keyword are known as

NonStatic variables.

aip
=>These NonStatic variables are categorized into two types:

(a)Instance variables
hM
(b)Local Variables

(a)Instance variables:
tes

=>The NonStatic variables which are declared outside the methods are known

as Instance variables or Object Variables.


a
nk

=>These Instance variables will get the memory within the object while

Object creation and can be accessed with Object name.


Ve

(b)Local Variables:

=>The NonStatic variables which are declared inside the methods are known

as Local variables or method Variables.

=>These Local variables will get the memory within the method while method
execution.

-----------------------------------------------------------

Ex-program : DemoVariables.java

class Test

ii
int x;

ath
static int y;

aip
class DemoVariables

{
hM
int a;

static int b;

public static void main(String[] args)


tes

DemoVariables.b=12;
a
nk

Test.y=13;

DemoVariables ob1 = new DemoVariables();


Ve

ob1.a=14;

Test ob2 = new Test();

ob2.x=15;

System.out.println("b value="+DemoVariables.b);

System.out.println("y value="+Test.y);
System.out.println("a value="+ob1.a);

System.out.println("x value="+ob2.x);

o/p:

ii
b value=12

ath
y value=13

a value=14

aip
x value=15
hM
==================================================================
a tes
nk
Ve

You might also like