0% found this document useful (0 votes)
13 views

JAVA

Static blocks are initialized first when a class is loaded into memory. Non-static methods require an instance to be called. When a class is instantiated, the instance block is called first followed by the default constructor. The new keyword creates memory for a class instance. Static variables can store values shared across all instances. Inheritance allows classes to extend functionality from a parent class.

Uploaded by

shashank gupta
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

JAVA

Static blocks are initialized first when a class is loaded into memory. Non-static methods require an instance to be called. When a class is instantiated, the instance block is called first followed by the default constructor. The new keyword creates memory for a class instance. Static variables can store values shared across all instances. Inheritance allows classes to extend functionality from a parent class.

Uploaded by

shashank gupta
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

1.

2.

3.
4.
5. Whenever class is loaded into heap memory static block is initialized first.
6.

7.
8. Method can be a static or non-static.
9.
10. For calling non-static method in main class we need to create instance of class first
then on using that instance we can call non-static methods
11.

12.
13.
14.

15.
16. Whenever a class is instantiated it will call it’s instance (non-static) block first.
17.

18.
19. Once the class is instantiated it will call the instance block first then it will call Default
constructor
20.
21. Oops example

22.
23. Reference variable always point to null
24. In the example below emp is a reference variable which is pointing to null.
25.
26. New key word creates a memory location to store class instance
27. Incase there is some variable whose value is same for all the instances of that class
we need to create static variable

28.
29. By defining variable as Private we can hide variable (data hiding and abstraction)
30. If we want to access these hidden variable we need to getter and setter.
31.

32.
33.
34. Inheritance

35.
36.

37.
38.

39.
40.
41. At the compile time object a will bind method eat and run of Animal call but at the
runtime reference a will point toward Monkey and hence method eat of monkey will
get bind to the reference a
42.

You might also like