Cognizant – Java Interview Questions
Here is the list Java Interview Questions which are recently asked in Cognizant company. These questions are included for both Freshers and Experienced professionals.
1. Explain JDK, JRE and JVM?
JDK stands for Java Development Kit is a software development kit whereas JRE expand as Java Runtime Environment is a software bundle that allows Java program to run, whereas JVM(Java Virtual Machine) is an environment for executing byte code.
2. Explain public static void main(String args[]) in Java
Public static void main (String[] args) Java main method is the entry point of any java program. Its syntax is always public static void main (String[] args) and can change the name of String array argument.
3. Why Java is platform independent?
Java is platform-independent because it does not depend on any type of platform. Hence, Java is platform-independent language and the programs are compiled into byte code and that byte code is platform-independent. Any machine to execute the byte code needs the Java Virtual Machine.
4. Why Java is not 100% Object-oriented?
Java is not a pure Object oriented language, but so called a "Hybrid" language. It supports primitive data type such as int ,char, float .All these are not object but you can argue we have wrapper class for each of the data type such Integer(int) , Float(float) etc . But as java supports primitive data type is the one main reason why it is not 100 % oops
5. What are wrapper classes in Java?
A Wrapper class is a class whose object wraps or contains primitive data types. When we create an object to a wrapper class, it contains a field and in this field, we can store primitive data types.
6. What are constructors in Java?
Constructor is a block of codes similar to the method. It is called when an instance of the class is created. It is a special type of method which is used to initialize the object. Every time an object is created using the new () keyword, at least one constructor is called.
7. What is singleton class in Java and how can we make a class singleton?
Singleton class is a class that can have only one object (an instance of the class) at a time. After first time, if we try to instantiate the Singleton class, the new variable also points to the first instance created.
Free PDF : Get our updated Java Course Content pdf
8. What is the difference between Array list and vector in Java?
Vector and ArrayList both uses Array internally as data structure. They are dynamically resizable. But, ArrayList increases by half of its size when its size is increased. Therefore as per Java API the only main difference is, Vector's methods are synchronized and ArrayList's methods are not synchronized.
9. What is the difference between equals() and == in Java?
equals() method for content comparison. == checks if both objects point to the same memory location whereas . equals() evaluates to the comparison of values in the objects.
10. What are the differences between Heap and Stack Memory in Java?
The major difference between Stack memory and heap memory is that the stack is used to store the order of method execution and local variables while the heap memory stores the objects and it uses dynamic memory allocation and deallocation.
11. What is a package in Java? List down various advantages of packages.
Java package is used to categorize the classes and interfaces so that they can be easily maintained. It provides access protection and removes naming collision.
12. Why pointers are not used in Java?
Java doesn't have pointers because it doesn't need them for general purpose OOP programming. Adding pointers to Java would undermine security and robustness and make the language more complex.
13. What is JIT compiler in Java?
The JIT compiler aids in improving the performance of Java programs by compiling bytecode into native machine code at run time. It helps improve the performance of Java programs by compiling bytecodes into native machine code at run time.
14. What are access modifiers in Java?
Access modifiers in Java allow to set the scope or accessibility or visibility of a data member be it a field, constructor, class, or method. Java also provides non-access specifiers that are used with classes, variables, methods, constructors, etc.
15. Define a Java Class.
Access modifiers in Java allow to set the scope or accessibility or visibility of a data member be it a field, constructor, class, or method. Java also provides non-access specifiers that are used with classes, variables, methods, constructors, etc.
Get Answer for all the above questions and place in your dream company
Wants to Become an Expert
in Java?
Know MoreTOP MNC's JAVA INTERVIEW QUESTIONS & ANSWERS
Here we listed all Java Interview Questions and Answers which are asked in Top MNCs. Periodically we update this page with recently asked Questions, please do visit our page often and be updated in Java.