Topic 1.5: Java Basics - Compare and contrast the features and components of Java such as: platform independence, object orientation, encapsulation, etc Flashcards
these include:
- arithmetic operators
- assignment operators
- comparison operators
- and logical operators.
What are the different types of operators in Java?
What is the role of the Java Virtual Machine (JVM) in achieving platform independence?
This acts as an interpreter or a just-in-time (JIT) compiler that executes the bytecode generated by the Java compiler. It translates the bytecode into machine code specific to the underlying platform.
These include:
- Logical AND (&&)
- Logical OR (||)
- Logical NOT (!)
Give examples of logical operators in Java.
the rules for these are:
- They cannot be a Java keyword
- they must start with a letter, underscore (_), or dollar sign ($)
- they can contain letters, digits, underscores, and dollar signs.
What are the rules and conventions for Java identifiers?
What is platform independence in Java?
this in Java refers to the ability of a program to run on different platforms or operating systems without requiring any modifications or recompilation.
The two main categories of these in Java are:
- primitive
- reference
What are the two main categories of data types in Java?
What are identifiers in Java?
these are names given to variables, classes, methods, and other elements in Java. They are used to uniquely identify these elements within a program.
Define abstraction
Representing essential features of an object and hiding unnecessary complexities
The ability of objects to take on many forms and exhibit different behaviors based on their types or classes
Define polymorphism
Explain the usage of the access modifier public
these members can be accessed from any class or package and have the broadest scope of visibility.
Explain the usage of the access modifier private
These members are accessible only within the same class, providing a level of data encapsulation.
How does encapsulation support code maintenance in Java?
Encapsulation facilitates this in Java by enabling modifications to the internal implementation of a class without impacting the external code dependent on its public interface.
This reduces the ripple effect of changes and enhances code maintainability.
Representing essential features of an object and hiding unnecessary complexities
Define abstraction
How does encapsulation protect the object’s internal representation?
This protects the object’s internal representation by providing controlled access to its data through public methods.
These methods regulate interactions with the object and ensure that its internal state remains secure.
these include:
- Equal to (==)
- Not equal to (!=)
- Greater than (>)
- Less than (<)
- Greater than or equal to (>=)
- Less than or equal to (<=)
Give examples of comparison operators in Java.
These members are accessible only within the same class, providing a level of data encapsulation.
Explain the usage of the access modifier private
What are the steps to create encapsulated classes in Java?
steps to accomplish this are:
- Declare class variables as private
- Provide public getter and setter methods
- Implement validation and business logic.
What is the “Write Once, Run Anywhere” principle associated with Java?
This principle means that developers can write Java code once and expect it to run on any platform that supports Java, eliminating the need for platform-specific code.
This acts as an interpreter or a just-in-time (JIT) compiler that executes the bytecode generated by the Java compiler. It translates the bytecode into machine code specific to the underlying platform.
What is the role of the Java Virtual Machine (JVM) in achieving platform independence?
What is the relationship between objects, classes, and inheritance?
An object is an instance of a class, representing a specific entity or concept.
A class is a blueprint or template for creating objects.
Inheritance is a mechanism in which one class inherits the properties and behaviors of another class, promoting code reuse and allowing for the creation of class hierarchies.
benefits of this include:
- Simplified development: this allows developers to focus on writing code without worrying about platform-specific details. They can write code once and expect it to run on any platform, saving time and effort.
- Reduced maintenance effort: Since Java programs can run on multiple platforms without modifications, updates or bug fixes only need to be applied once. This reduces the maintenance effort required for supporting different platforms.
- Widespread support: this feature has made java popular across various industries and platforms. It is widely supported, ensuring compatibility and availability of Java applications on different operating systems and devices.
What are the benefits of platform independence in Java?
these include:
- Compiled languages: In compiled languages, the source code is translated into machine code before execution. Examples include C, C++, and Swift.
- Interpreted languages: In interpreted languages, the source code is executed line by line by an interpreter. Examples include Python, JavaScript, and Ruby.
- JIT (Just-In-Time) compiled languages: JIT languages combine elements of both compiled and interpreted languages. The source code is initially compiled into an intermediate representation (bytecode) and then dynamically compiled into machine code during runtime. Java and C# are examples of JIT compiled languages.
What are the three main types of programming languages?
these members can be accessed from any class or package and have the broadest scope of visibility.
Explain the usage of the access modifier public
Encapsulation facilitates this in Java by enabling modifications to the internal implementation of a class without impacting the external code dependent on its public interface.
This reduces the ripple effect of changes and enhances code maintainability.
How does encapsulation support code maintenance in Java?