Chapter 4 Flashcards
What is use of constructor
For object initialization
What are access modifiers
Public (accessible from everywhere) Private (accessible within a class) Protected (accessible class and sub classes) Package access (by default : accessible within current directory)
What is setter
It is a function that assign value to any variable. It helps in validation.
What about constructors
Constructors are public and they do not have any return type.
Does we define destructor in Java
No
What is the only way in Java to make object
new operator
Do we use -> operator in java
No
What are static variable
It is such variable which does not belong to object, but it belongs to class. Unlike instance variable belongs to object.
Does non-static member can be called from static
No
Is memory management in java automatic
Yes
Does java use garbage collection and what is its role
Yes. Garbage collection is for memory management
What is command of garbage collection
system.gc
What finalize do
It do works as we do in destructor
Which is the main class of java and by which every class is inherited
Object class
What toString method do
It converts any object state into string and return