1.What is Java?
- Java is object-oriented, platform-independent, Multithreaded, and portable programming language.
- it provides its own JRE and API.
2.What is the difference between JDK, JRE, and JVM?
JVM
- Java Virtual Machine provides the runtime environment
- JVM converts Java bytecode into machine language
JRE
- Java Runtime Environment make java program to run
- It contains the class libraries, loader class, and JVM.
- JRE provide the runtime environment.
JDK
- Java Development Kit contains tools can write Java programs and JRE to execute them.
- It includes a compiler, Java application launcher
- JDK includ JRE and JVM
3. What is Object-Oriented?
- object-oriented programming is about creating objects that contain both data and methods.
- advantages
- OOP is faster and easier to execute
- we don’t need to repeat
- The code easier to maintain, modify and debug
- OOP can reuse before code and reduce development time
4. what is Multithreaded?
- programs can deal with many tasks at once
- programs doesn’t occupy memory for each thread and share a common memory area.
5.What are the various access specifiers in Java?
- access specifiers are used to define the access scope of the method, class, or a variable
Public
The classes, methods, or variables are defined as public,
it can be accessed by any class or method.
Protected
Protected can be accessed by the class of the same package, or by the sub-class of this class, or within the same class.
Default
Default are accessible within the package only.
Private
private can be accessed within the class only.
6. What is the purpose of static methods and variables?
- The methods or variables defined as static are shared among all the objects of the class. - The static is the part of the class and not of the object.
- The static variables are stored in the class area, and we do not need to create the object to access such variables.
7. What are the advantages of Packages in Java?
- Packages avoid the name clashes.
- The Package provides easier access control.
- We can also have the hidden classes that are not visible outside and used by the package.
- It is easier to locate the related classes.
8. What is an object?
- Java object is a member (instance) of a Java class
- Each object has an identity, a behavior and a state.
- The state of the object is stored in fields (variables), methods (functions) display the object’s behavior.
- In Java, an object is created using the keyword “new”.
9.What is the difference between an object-oriented programming language and object-based programming language?
Object Based Languages
- Object based languages supports the usage of object and encapsulation.
- They does not support inheritance or, polymorphism or, both.
- Object based languages does not supports built-in objects.
- Javascript, VB are the examples of object bases languages.
Object Oriented Languages - Object Oriented Languages supports all the features of Oops including inheritance and - polymorphism.
- They support built-in objects.
- C#, Java, VB. Net are the examples of object oriented languages.
10.What is the constructor?
- The constructor is special method that is used to initialize the object.
- It is invoked when the class is instantiated, and the memory is allocated for the object.
- Every time, an object is created using the new keyword, the default constructor of the class is called.
- The name of the constructor must be similar to the class name.
- The constructor must not have an explicit return type.