Jav 1
Jav 1
faq:
define "Object"?
ii
syntax of Object Creation:
ath
Class_name obj_name = new Class_name();
==================================================================
aip
(a)Classes in Java:
1.Pre-defined classes
tes
1.Pre-defined classes:
=>The classes which are ready constructed and available from JavaLib are
Ve
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.
=>The variables which are declared with primitive datatypes like byte,
variables.
=>The variables which are declared with NonPrimitive datatypes like Class,
ii
===================================================================
ath
===
*imp
aip
=>"static" keyword in Java "will specify the location of Programming
=>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
=>These static variables will get the memory within the class while class
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
=>These Instance variables will get the memory within the object while
(b)Local Variables:
=>The NonStatic variables which are declared inside the methods are known
=>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;
DemoVariables.b=12;
a
nk
Test.y=13;
ob1.a=14;
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