Constant:
- Value Fixed jgrh gSaA
Variables,
Java Programs esa
Basic Storage ds fy, dke esa fy;s tkrs
gSaA Variables, Identifiers, Type rFkk Initializer dk Combination
gksrk gSaA Variable dk Scope mudh Visibility rFkk Life Time dks n’kkZrk gSaA
Variables
Declaration: - Java esa Variable dks muds mi;ksx
ls igys Declare fd;k tkrk gSaA
Syntax:
- Type Identifier = Value;
;gka ij Type,
Java dh Data Type esa ls dksbZ ,d Type gksrh
gSa tks fd Class dk uke ;k Interface gks ldrk gSaA Identifiers,
Variables dk
uke gksrk gSaA
Dynamic
Initialization of Variables: -Variables
ds Dynamic Initialization esa uhps fy[ks Program ds varxZr 2
Variables dks
Double Value ls Initialize fd;k tkrk gSaA rFkk rhljk Variable es mUgha Value
dks dke esa
ysrs gq, ge Variable dk Dynamic Initialize djrs gSAValid
Expressions dks
dke esa ysdj B Variable Declaration Allow
djrh gSaA
class
My
{
public static vaid main (String a [])
{
double a = 3.0;
double b = 4.0;
double c;
c =
Math.sqrt (a*a+b*b);
class method
System.out.println (“The Square root of a and b is:”+ c);
}
}
Scope&
Life time Variables:- dksbZ Hkh Variable Main Method ds vanj gh Declare fd;k
tkrk gSaA ysfdu Java, Variables dks fdlh Hkh Block esa Declare djus dh vuqefr nsrh gSaA Block, Middle Bracket ({}) ls 'kq: gksrk gSaA rFkk
mlh ds lkFk [kRe gksrk gSa rFkk Block ds }kjk gh Variable dk Scope r; fd;k tkrk gSaA cgqr lh Language, Variables ds Scopes
dks 2 Categories esa divide djrh gSaA
(i)
Global (ii) Local
Perl,
Java esa cgqr
ls Global Variable Scope dks mi;ksx esa fy;k tk
ldrk gSaA Java vius&vius vyx Scope: -
(i) Variables Defined By Class.
(ii) Variables Defined by Methods
dks ifjHkkf"kr djrk gSaA Class ds }kjk Define fd;s x;s Variable dh dqN Unique
Properties rFkk
Attributes gksrs gSaA tks mls Method esa Define
Variable ls
vyx djrs gSaA
Scope
ftls Method ds }kjk define
fd;k x;k gSaA
{} ls 'kq: gksrs gSa] rFkk mudk Scope {} ds can gksus rd jgrk gSaA vr% ;g dg ldrs gSa fd Java Hkh Local o Global Variable dks fHkUu djrh gSaAmUgsa Access fd;k tk ldrk gSaA Scope dks
Nested Hkh fd;k tk ldrk gSaA
No comments:
Post a Comment