Thursday, January 3, 2019

Static is a keyword in Java, which is used for
    1. static blocks
    2. variables
    3. methods and 
    4. inner classes or nested classes
  • A static member can be accessed directly with the class name with out creating an object. 
  • The value of the  static variable is shared by all objects of a class means same set of copy available to all the objects.
  • If any variable is modified by an object those changes visible to every object. Static content doesn't belongs to any particular instance or object.
Static can not be used for Outer most class class. Why?
  1. Every class is already common to all the objects. No need to make class static to become available to all the objects
  2. A class is belongs to package level. Class can be accessed directly with <package_name.ClassName>. No need to make class as static.

Related Posts:

  • What is Manual Testing and its Advantages, Limitations Manual testing is a testing process that is carried out manually(executing test cases) in order to find defects without the usage of tools or automation scripting. It is the most primitive of all testing types and… Read More
  • Encapsulation in Java Encapsulation is to make sure that "sensitive" data is hidden from users. To achieve this, you must: declare class variables/attributes as private (only accessible within the same class) provide public setter and getter m… Read More
  • Retrieve Test Data from an Excel file with Apache POI A Java Program to retrieve the data from an excel file?   Below is the code to read .xlsx file.                                XSSFWorkbo… Read More
  • Why String is Immutable? What is mean by immutable object/class? Assume we have a below class A as mutable: Class A{ int i = 10; int j = 20; A a = new A(); } a.i = 30; a.j = 40; Changing state of objects, so A is mutable. Immutable: once o… Read More
  • ArrayList vs LinkedList Difference between ArrayList and LinkedList? Similarities: Both implements List interface(linkedlist also implements deque interface), maintains insertion order and can contain duplicate elements. Both are non synchroni… Read More

0 comments:

Post a Comment

Selenium Training in Realtime

Blog helps to a student or IT employee to develop or improve skills in Software Testing.

Followers

About Me

My photo
Hyderabad, Andhra Pradesh, India
I am Automation Testing Professional. I have completed my graduation in B.Tech (Computers) from JNTU Hyderabad and started my career in Software Testing accidentally since then, I passionate on learning new technologies

Contact Form

Name

Email *

Message *

Popular Posts