Java Interview Question and Answer Explain Static,Interface,Abstract class

preview_player
Показать описание

"static" can be used in four ways:

static variables are shared by the entire class, not a specific instance (unlike normal member variables)

static methods are also shared by the entire class

static classes are inner classes that aren't tied to their enclosing classes

static can be used around a block of code in a class to specify code that runs when the virtual machine is first started up, before instances of the class are created.

2. What are the differences between interfaces, abstract classes, classes, and instances ?
Interfaces are essentially a list of methods that implementations must possess, but have no code or member variables
Abstract classes cannot be instantiated, but can contain variables, implemented methods, and unimplemented methods
Classes contain variables and implemented methods only, and can be instantiated
Instances (or objects) are specific examples of a particular class.
Рекомендации по теме
visit shbcf.ru