0% found this document useful (0 votes)
15 views5 pages

Understanding Static Variables in Java

Uploaded by

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

Understanding Static Variables in Java

Uploaded by

suranaishah
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Advanced class features

1) Static variables & methods


2) Nested class
Static variable

Static method
Test class (driver class) – what is the output?

public class TestStudent


{ public static void main(String[] args) {

Student stud1 = new Student(“Ali”, 23);


Student stud2 = new Student(“Abu”, 20); // Instantiate 3 Student objects

Student stud3 = new Student(“Aini”, 18);

[Link](stud1);
[Link](stud2); // calling implicit toString()

[Link](stud3);

[Link]( “Each student need to pay RM”+ [Link]()+ “athletic fee”);


} //end class
Output

display once only!


So what is static variable ?
Why and when you need it ?
 Your Answer:

You might also like