-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest_LocalVariable.java
More file actions
48 lines (34 loc) · 993 Bytes
/
Test_LocalVariable.java
File metadata and controls
48 lines (34 loc) · 993 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package com.May2023;
public class Test_LocalVariable extends Parent2
{
int var = 12 ;
public void test1()
{
//variable is getting altered locally and it's value is limited to this method only
var= 123 ;
System.out.println("Print value of var(method):- "+var);
}
public void test2()
{
str= "def";
System.out.println("this.str:- "+this.str);
System.out.println("super.str:- "+super.str);
}
public static void main(String[] args)
{
Test_LocalVariable local = new Test_LocalVariable();
System.out.println("Print value of var(main method):- "+local.var);
local.test1();
System.out.println("Print value of var(main method):- "+local.var);
System.out.println("******");
System.out.println("Print str value:- "+local.str);
local.test2();
System.out.println("Print str value:- "+local.str);
//local.var = 100 ;
//System.out.println();
}
}
class Parent2
{
String str = "abcd";
}