Perguntas processo seletivo Java - Parte I
Este é o primeiro post com a compilação de algumas perguntas técnicas em inglês sobre Java.
Estas perguntas, além de já ter sido utilizadas em entrevistas, são também uma forma de conhecer mais a linguagem.
Quando comecei a estudar algumas dessas perguntas, percebi que alguns termos e algumas explicações eu não sabia, apesar de trabalhar com Java já há algum tempo. E isso também está me motivando a aprender mais a fundo algumas coisas.
Espero que gostem da compilação que fiz! :)
Lembrem-se também que estas respostas não são para você ler durante a entrevista. O objetivo é aprender os termos em inglês e ter uma idéia de que resposta dar.
Bem, vamos começar então! Hoje vou postar algumas perguntas relacionadas à tecnologia Java em geral e OO.
Question: What is the difference between C++ and Java?
A: Both C++ and Java use similar syntax and are Object Oriented, but:
- Java does not support pointers. Pointers are inherently tricky to use and troublesome.
- Java does not support multiple inheritances because it causes more problems than it solves. Instead Java supports multiple interface inheritance, which allows an object to inherit many method signatures from different interfaces with the condition that the inheriting object must implement those inherited methods. The multiple interface inheritance also allows an object to behave polymorphically on those methods.
- Java does not support destructors but adds a finalize() method. Finalize methods are invoked by the garbage collector prior to reclaiming the memory occupied by the object, which has the finalize() method. This means you do not know when the objects are going to be finalized. Avoid using finalize() method to release nonmemory resources like file handles, sockets, database connections etc because Java has only a finite number of these resources and you do not know when the garbage collection is going to kick in to release these resources through the finalize() method.
- Java does not include structures or unions because the traditional data structures are implemented as an object oriented framework.
- All the code in Java program is encapsulated within classes therefore Java does not have global variables or functions.
- C++ requires explicit memory management, while Java includes automatic garbage collection.
Question: What are the advantages of Object Oriented Programming Languages (OOPL)?
A: The Object Oriented Programming Languages directly represent the real life objects like Car, Jeep, Account, Customer etc. The features of the OO programming languages like polymorphism, inheritance and encapsulation make it powerful. [Tip: remember pie which, stands for Polymorphism, Inheritance and Encapsulation are the 3 pillars of OOPL]
Question: How does the Object Oriented approach improve software development?
A: The key benefits are:
- Re-use of previous work: using implementation inheritance and object composition.
- Real mapping to the problem domain: Objects map to real world and represent vehicles, customers, products etc: with encapsulation.
- Modular Architecture: Objects, systems, frameworks etc are the building blocks of larger systems.
Até a próxima!