Java classes
class TestClass{ int number; void testMethod(TestClass t) { t.number=25; System.out.println("Inside the Testclass, test method "+ t.number); } } public class Main { public static void testMethod(int number) { number = 25; System.out.println("Inside the testMethod "+ number ); } public static void main(String[] args) { //scenario 1 int number=45; testMethod(number); System.out.println("Inside the main method "+ number); //scenario 2 TestClass t=new TestClass();//object initialization t.number=45; t.testMethod(t); System.out.println("Inside the Main Method "+t.number); } } In the second scenario println part why does it get printed as 25 but not 45? What happens there?