fbpx

1. What are the advantages of using an object-oriented programming language like Java?

Few software products are coded from scratch. By using objects, programmers can abstract complex data structures, encapsulating them into an object. Software products can be built upon these underlying structures. Programmers can use these data structures, using objects that contain certain data points and functions without having to understand the underlying code. By using objects, the code is easier to reuse, repurpose and recycle.

2.Can you explain what a Java Virtual Machine is?

The Java Virtual Machine (JVM) makes Java software applications portable. Portability refers to the capability of a software program to work on any device or operating system. Code written on a computer loaded with a Microsoft operating system will perform equally as well on a Mac or a Linux computer, for example. The user needs a JVM to run Java applications. Without a JVM, the application will fail to execute.

3.What is the final keyword in Java?

The final keyword restricts the usage of a variable, class or method. Once the final keyword has been assigned to a variable, the value cannot be changed. The variable is made constant since its value cannot be modified. It’s best to initialize a final variable when it is declared, although a blank final variable can be declared without being initialized. It’s important to note that a final variable only can be initialized once. A class with the final keyword cannot be inherited or extended. Final classes can be used to prevent inheritance or to create an immutable class. A method with the final keyword cannot be hidden or overridden by subclasses. A method cannot be both final and abstract, since abstract methods rely on inheritance to be fully implemented.

4. Why is commenting and organizing your code important?
Code is seldom written from scratch. It’s important to write clear, concise comments so it is easy to understand how to use and build upon the classes and methods you’ve created. Without properly organizing, spacing and commenting code, it will take much longer for other programmers to make sense of it, slowing down development and causing unnecessary complication. Guidelines for clean code should be set by the team or the company creating the code. Every company is different, employing different strategies for keeping code clean

, but it is important to make sure these strategies are used consistently by every member of the team.

5 Is multiple inheritance supported in Java?

Multiple inheritance is a concept used in object-oriented programming languages. Using multiple inheritance, a class can inherit properties of more than one parent class. Java does not support multiple inheritance because parent classes with the same signature can complicate compilation, as it is impossible to establish the order and priority for parent function calls, although experienced Java developers can work around this. Multiple inheritance is not directly supported; multiple inheritance can be achieved in Java through interfaces.

6. What does platform independence mean? Why is it useful?

Platform independence means an application is not dependent on the machine or the operating system it executes on. Java compiles source code into bytecode. This bytecode then is converted into machine code by the Java Virtual Machine. The Java Virtual Machine needs to be installed on the user’s machine for any Java application to run correctly. For this reason, the Java Virtual Machine can be installed on every operating system. Platform independence is useful because it means code only needs to be written once to run on every machine. Platform independence makes developing much faster and easier and is absolutely necessary for modern software projects.

Leave a Reply

×