07 Solution Java Exercise

07 Solution Java Exercise

07 Solution Java Exercise

Question 07

Define the following Java concepts

    1. private, public and protected

    2. constructor

    3. JRE, JDK, JVM

    4. Super keyword


1. Private, Public, and Protected:

   Private: A private member (variable or method) of a class is only accessible within that class. It cannot be accessed or modified by code outside the class.

   Public: A public member is accessible from any class. It can be accessed and modified by any code that can access the class.

    Protected: A protected member is accessible within the same package and subclasses (even if they are in different packages). It is not accessible to the world outside the package or to unrelated classes.

2. Constructor:

   A constructor in Java is a special method that is used to initialize objects. It is called when an instance of a class is created using the `new` keyword. Constructors have the same name as the class and do not have a return type. They are used to set initial values for object attributes.

3. JRE, JDK, JVM


   JRE (Java Runtime Environment): This is a software package that provides the Java Virtual Machine (JVM) along with some tools and libraries necessary for running Java applications. It includes the Java class libraries, the Java class loader, and the Java Virtual Machine.

   JDK (Java Development Kit): This is a software development environment used for developing Java applications and applets. It includes the JRE, development tools, compilers, and other resources needed to develop and run Java programs.

   JVM (Java Virtual Machine): This is an abstract computing machine that enables a computer to run Java programs. It interprets compiled Java bytecodes and executes them.

4. Super Keyword:

   The super keyword in Java is a reference variable that is used to refer to the immediate parent class object. It can be used to access methods and variables of the parent class. It is especially useful when the subclass has overridden a method and you want to call the parent class' implementation.




0 Response to "07 Solution Java Exercise"

Post a Comment