/
Java Programming Concepts and OOP Fundamentals
Save to my account
Sign up
Java Programming Concepts and OOP Fundamentals
Java Programming Concepts and OOP Fundamentals
Study
1
Question
What is the difference between procedural programming and object-oriented programming (OOP)?
Answer
Procedural programming executes instructions in a step-by-step literal order, guiding the application through sequences of commands, while OOP views program components as objects similar to real-world entities, focusing on creating and using these objects, which better suits complex and multifaceted problems.
2
Question
List and briefly explain the five main features of Object-Oriented Programming (OOP).
Answer
1. Encapsulation: Capturing data and protecting it from outside access. 2. Inheritance: Creating a new class from a base class, inheriting features and adding new ones, enhancing code reusability. 3. Polymorphism: The ability of objects to exist in various forms. 4. Abstraction: Representing data conceptually without details, hiding information from other classes. 5. Message Passing: Objects communicate by invoking methods and sending data through function parameters.
3
Question
Why is Object-Oriented Programming considered better suited for most tasks compared to procedural programming?
Answer
Because most problems are complex and multifaceted and do not conform easily to a linear approach, OOP's conceptualization of program components as interacting objects provides a more flexible and natural modeling of such problems.
4
Question
What was the original purpose behind the development of the Java programming language in 1991?
Answer
Java was designed by James Gosling and his team at Sun Microsystems to programming home appliances controlled by various computer processors, requiring a language accessible across different hardware.
5
Question
How did Java's connection to the internet begin and which company was involved?
Answer
In 1994, James Gosling realized Java's suitability for web browsers, and in 1995 Netscape Incorporated released a browser version capable of running Java programs, marking Java's strong connection to the internet.
6
Question
What was the original name of the Java programming language and why was it changed?
Answer
The original name was Oak, but it was changed because a programming language already existed with that name. After struggling to find a new name, the development team went out for coffee and the name Java was born.
7
Question
Is Java only a programming language for Internet applications?
Answer
No, Java is a general all-purpose language that can be used independently of the Internet, despite being viewed as a language for designing Internet applications.
8
Question
What does Java stand for?
Answer
Java does not stand for "Just Another Vague Acronym." It is both a programming language and a platform.
9
Question
Who developed the Java programming language and what type of language is it?
Answer
Java was developed by SUN Microsystems (Stanford University Network) as an object-oriented language used for general-purpose business programs and interactive internet programs.
10
Question
What are some advantages of the Java programming language that have contributed to its popularity?
Answer
Its security features and architectural neutrality, meaning Java programs can run on any platform.
11
Question
List the characteristics that describe Java as a high-level programming language.
Answer
Java is simple, architecture-neutral, object-oriented, portable, distributed, high-performance, interpreted, multithreaded, robust, dynamic, and secure.
12
Question
How does the compilation and interpretation process work in Java?
Answer
Java programs are first compiled into an intermediate language called Java bytecodes. These bytecodes are platform-independent and are interpreted by the Java interpreter each time the program runs. Compilation happens once, interpretation happens every execution.
13
Question
What is the role of Java bytecodes?
Answer
Java bytecodes are the machine code instructions for the Java Virtual Machine (Java VM) and enable the 'write once, run anywhere' capability by being platform-independent.
14
Question
What is the Java Virtual Machine (Java VM)?
Answer
The Java VM is an implementation (either a software Java interpreter or hardware) that runs Java bytecodes. Every Java interpreter, including browsers running applets, is an implementation of the Java VM.
15
Question
How does the Java platform differ from most other platforms?
Answer
The Java platform is a software-only platform that runs on top of other hardware-based platforms, unlike most platforms that combine hardware and operating systems.
16
Question
What are the two main components of the Java platform?
Answer
The two main components of the Java platform are the Java Virtual Machine (Java VM) and the Java Application Programming Interface (Java API).
17
Question
What is the role of the Java Virtual Machine (Java VM)?
Answer
The Java VM serves as the base for the Java platform and is ported onto various hardware-based platforms, enabling Java programs to run independently of underlying hardware.
18
Question
What does the Java API provide?
Answer
The Java API is a large collection of ready-made software components grouped into libraries (packages) that provide many useful capabilities, such as graphical user interface (GUI) widgets.
19
Question
How does the Java platform ensure program portability across different hardware?
Answer
The Java API and Java Virtual Machine isolate Java programs from hardware dependencies, creating a platform-independent environment.
20
Question
Why might Java programs run slower than native code, and how is this performance gap addressed?
Answer
Java programs can be a bit slower than native code due to the platform-independent layer, but smart compilers, well-tuned interpreters, and just-in-time bytecode compilers help bring Java's performance close to native code without sacrificing portability.
21
Question
What is a Java applet?
Answer
A Java applet is a Java program that follows certain conventions allowing it to run within a Java-enabled browser.
22
Question
What is the difference between a Java applet and a Java application?
Answer
A Java applet runs within a Java-enabled browser following specific conventions, while a Java application is a standalone program that runs directly on the Java platform.
23
Question
In the provided HelloWorld example, what is the purpose of the 'public class HelloWorld' statement?
Answer
It defines a class named HelloWorld, with 'public' as an access modifier specifying that the class can be accessed liberally.
24
Question
What does the 'public' access modifier signify in Java?
Answer
It indicates the most liberal type of access, meaning the class or member can be accessed from any other class.
25
Question
What are the three types of comments in Java, and what are their uses?
Answer
1) Documentation comments: used at the beginning of the program; 2) Block comments: used to comment a block or multiple lines; 3) Line comments: used to comment a single line of the program.
26
Question
What does the keyword 'static' mean in the context of the main method in Java?
Answer
Static means unchanging or stationary, indicating that every member created for the class (like the main method) belongs to the class itself rather than to any instance of the class.
27
Question
What is the role of the argument 'String args' in the main method?
Answer
'String args' is an argument that holds any Strings sent to the main method. It provides information the method requires to perform its task.
28
Question
Why is the identifier 'args' used in the main method's parentheses, and can it be named differently?
Answer
By convention, 'args' is used as the identifier, but it can be any legal Java identifier. You must place an identifier within the main method's parentheses even if it is not used.
29
Question
What is the purpose of the statement 'System.out.println("Hello World!")' in Java?
Answer
This statement displays 'Hello World!' on the screen. 'System' is a class, 'out' is an object representing the screen, and 'println' is a method that prints a line of output and moves the cursor to the next line.
30
Question
How are classes, objects, and methods represented in the statement 'System.out.println'?
Answer
The dots separate the class (System), the object (out), and the method (println). This shows the hierarchical relationship between them.