viva java
viva java
In Java, you declare a variable by specifying its data type and name, like this:
int myVariable;. Primitive data types in Java are types that represent basic types
of data, like integers, floating-point numbers, and booleans. Reference data types
in Java are types that refer to objects, like strings or arrays.
Access modifiers in Java are keywords that are used to control the visibility and
accessibility of classes, methods, and variables. The four access modifiers in Java
are public, private, protected, and package-private (also known as default).
Inheritance in Java is a mechanism by which one class can inherit the properties
and methods of another class. Inheritance is used to create classes that are based
on existing classes, but with additional functionality or changes to the existing
functionality.
The "==" operator in Java tests for reference equality, while the .equals() method
tests for value equality. In other words, "==" checks if two objects are the same
object in memory, while .equals() checks if two objects have the same values.
A static method in Java is a method that belongs to a class rather than to any
particular instance of the class. The main difference between a static method and
an instance method is that a static method can be called on the class itself, while
an instance method is called on an instance of the class.