Topic 1.5: Java Basics - Compare and contrast the features and components of Java such as: platform independence, object orientation, encapsulation, etc Flashcards

1
Q

these include:

  • arithmetic operators
  • assignment operators
  • comparison operators
  • and logical operators.
A

What are the different types of operators in Java?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the role of the Java Virtual Machine (JVM) in achieving platform independence?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

These include:

  • Logical AND (&&)
  • Logical OR (||)
  • Logical NOT (!)
A

Give examples of logical operators in Java.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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.
A

What are the rules and conventions for Java identifiers?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is platform independence in Java?

A

this in Java refers to the ability of a program to run on different platforms or operating systems without requiring any modifications or recompilation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

The two main categories of these in Java are:

  • primitive
  • reference
A

What are the two main categories of data types in Java?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are identifiers in Java?

A

these are names given to variables, classes, methods, and other elements in Java. They are used to uniquely identify these elements within a program.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Define abstraction

A

Representing essential features of an object and hiding unnecessary complexities

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

The ability of objects to take on many forms and exhibit different behaviors based on their types or classes

A

Define polymorphism

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Explain the usage of the access modifier public

A

these members can be accessed from any class or package and have the broadest scope of visibility.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Explain the usage of the access modifier private

A

These members are accessible only within the same class, providing a level of data encapsulation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How does encapsulation support code maintenance in Java?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Representing essential features of an object and hiding unnecessary complexities

A

Define abstraction

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How does encapsulation protect the object’s internal representation?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

these include:

  • Equal to (==)
  • Not equal to (!=)
  • Greater than (>)
  • Less than (<)
  • Greater than or equal to (>=)
  • Less than or equal to (<=)
A

Give examples of comparison operators in Java.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

These members are accessible only within the same class, providing a level of data encapsulation.

A

Explain the usage of the access modifier private

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What are the steps to create encapsulated classes in Java?

A

steps to accomplish this are:

  1. Declare class variables as private
  2. Provide public getter and setter methods
  3. Implement validation and business logic.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is the “Write Once, Run Anywhere” principle associated with Java?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

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.

A

What is the role of the Java Virtual Machine (JVM) in achieving platform independence?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What is the relationship between objects, classes, and inheritance?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

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.
A

What are the benefits of platform independence in Java?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

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.
A

What are the three main types of programming languages?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

these members can be accessed from any class or package and have the broadest scope of visibility.

A

Explain the usage of the access modifier public

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

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.

A

How does encapsulation support code maintenance in Java?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

These in Java are used to compare two values and return a boolean result.

A

What are comparison operators used for in Java?

26
Q

What are operators in Java?

A

these in Java are symbols that perform specific operations on one or more operands and produce a result.

27
Q

What advantage does encapsulation provide in Java?

A

this offers the benefit of data hiding, which safeguards the internal state of an object from direct access by other classes.

28
Q

Give examples of comparison operators in Java.

A

these include:

  • Equal to (==)
  • Not equal to (!=)
  • Greater than (>)
  • Less than (<)
  • Greater than or equal to (>=)
  • Less than or equal to (<=)
29
Q

Define encapsulation

A

Bundling data and methods together into objects and hiding internal implementation details.

30
Q

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.

A

How does encapsulation protect the object’s internal representation?

31
Q

Give examples of logical operators in Java.

A

These include:

  • Logical AND (&&)
  • Logical OR (||)
  • Logical NOT (!)
32
Q

this in Java refers to the ability of a program to run on different platforms or operating systems without requiring any modifications or recompilation.

A

What is platform independence in Java?

33
Q

Java achieves this by compiling programs into bytecode, which can be executed on any platform that has a compatible Java Virtual Machine (JVM) installed.

A

How does Java achieve platform independence?

34
Q

this offers the benefit of data hiding, which safeguards the internal state of an object from direct access by other classes.

A

What advantage does encapsulation provide in Java?

35
Q

What are the three main types of programming languages?

A

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.
36
Q

Bundling data and methods together into objects and hiding internal implementation details.

A

Define encapsulation

37
Q

What is encapsulation in Java?

A

This is a principle in object-oriented programming that combines data and methods into a single unit called a class.

It involves hiding the internal state and implementation details of an object from external access and manipulation.

38
Q

What are primitive data types in Java?

A

These data types in Java are the fundamental building blocks that represent basic values. They are not objects and do not have any methods or properties associated with them.

39
Q

What are the key principles of object-oriented programming (OOP)?

A

The key principles of This are

  • encapsulation
  • abstraction
  • polymorphism
  • and inheritance.
40
Q

How does Java achieve platform independence?

A

Java achieves this by compiling programs into bytecode, which can be executed on any platform that has a compatible Java Virtual Machine (JVM) installed.

41
Q

How are primitive data types and reference types stored in memory?

A

Primitive data types are stored directly in memory and have a fixed size. Reference types are stored on the heap and accessed through references (memory addresses).

42
Q

What are the benefits of platform independence in Java?

A

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.
43
Q

these in Java are used to perform logical operations on boolean expressions.

A

What are logical operators used for in Java?

44
Q

What are the different types of operators in Java?

A

these include:

  • arithmetic operators
  • assignment operators
  • comparison operators
  • and logical operators.
45
Q

Define polymorphism

A

The ability of objects to take on many forms and exhibit different behaviors based on their types or classes

46
Q

Define inheritance

A

Creating new classes based on existing ones, allowing for code reuse and creating hierarchies of related classes.

47
Q

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.

A

What is the “Write Once, Run Anywhere” principle associated with Java?

48
Q

What are reference types in Java?

A

these types in Java, also known as objects, are more complex data types that can hold references to objects created from classes or arrays. They have methods and properties associated with them.

49
Q

Explain the usage of the access modifier protected

A

these members are accessible within the same class, subclasses, and other classes in the same package, mainly used for inheritance-related scenarios.

50
Q

This is a principle in object-oriented programming that combines data and methods into a single unit called a class.

It involves hiding the internal state and implementation details of an object from external access and manipulation.

A

What is encapsulation in Java?

51
Q

What are the rules and conventions for Java identifiers?

A

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.
52
Q

these are names given to variables, classes, methods, and other elements in Java. They are used to uniquely identify these elements within a program.

A

What are identifiers in Java?

53
Q

these in Java are symbols that perform specific operations on one or more operands and produce a result.

A

What are operators in Java?

54
Q

Creating new classes based on existing ones, allowing for code reuse and creating hierarchies of related classes.

A

Define inheritance

55
Q

these members are accessible within the same class, subclasses, and other classes in the same package, mainly used for inheritance-related scenarios.

A

Explain the usage of the access modifier protected

56
Q

These data types in Java are the fundamental building blocks that represent basic values. They are not objects and do not have any methods or properties associated with them.

A

What are primitive data types in Java?

57
Q

What are comparison operators used for in Java?

A

These in Java are used to compare two values and return a boolean result.

58
Q

What are logical operators used for in Java?

A

these in Java are used to perform logical operations on boolean expressions.

59
Q

these types in Java, also known as objects, are more complex data types that can hold references to objects created from classes or arrays. They have methods and properties associated with them.

A

What are reference types in Java?

60
Q

What are the two main categories of data types in Java?

A

The two main categories of these in Java are:

  • primitive
  • reference
61
Q

steps to accomplish this are:

  1. Declare class variables as private
  2. Provide public getter and setter methods
  3. Implement validation and business logic.
A

What are the steps to create encapsulated classes in Java?

62
Q

The key principles of This are

  • encapsulation
  • abstraction
  • polymorphism
  • and inheritance.
A

What are the key principles of object-oriented programming (OOP)?