Northcorp Software
30+ NISA Global Interview Questions and Answers
Q1. What is the diffrence between == and .equals() in java?
In Java, == compares memory addresses while .equals() compares the actual values of objects.
== compares memory addresses of objects
.equals() compares the actual values of objects
Use == for comparing primitive data types
Use .equals() for comparing objects like Strings
Q2. What is the difference between ==and .equals() in java?
In Java, == compares memory addresses while .equals() compares the actual content of objects.
== compares memory addresses of objects, while .equals() compares the actual content of objects.
== is used to compare primitive data types, while .equals() is used to compare objects.
Example: String str1 = new String("hello"); String str2 = new String("hello"); str1 == str2 will be false, but str1.equals(str2) will be true.
Q3. == : Compares refrences (memory addresses) of objects. .equals() : Compares to content (value) of objects.
The '==' operator compares memory addresses of objects, while the .equals() method compares the content or value of objects.
Use '==' for comparing memory addresses of objects.
Use .equals() for comparing the content or value of objects.
Example: String str1 = new String("hello"); String str2 = new String("hello"); str1 == str2 will return false, but str1.equals(str2) will return true.
Q4. 1 : Declare the class as final. 2 : Make all fields private and final. 3 : Provide no setter methods.
The question is asking to create a class with certain restrictions like being final, having private and final fields, and no setter methods.
Declare the class as final to prevent it from being subclassed.
Make all fields private and final to ensure encapsulation and immutability.
Provide no setter methods to enforce read-only access to the fields.
Q5. ==compares object references (memory location) .equals() compares the actual content or values of the objects.
The question explains the difference between == and .equals() in Java for comparing object references and content.
Use == to compare object references (memory location)
Use .equals() to compare the actual content or values of the objects
Example: String str1 = new String("hello"); String str2 = new String("hello"); str1 == str2 will be false, but str1.equals(str2) will be true
Q6. What is the purpose of the final keyword in Java?
The final keyword in Java is used to restrict the user from changing the value of a variable, making a method not overrideable, or preventing a class from being subclassed.
Final variables cannot be reassigned once initialized
Final methods cannot be overridden in subclasses
Final classes cannot be subclassed
Final parameters in a method cannot be modified within the method
Q7. What is the purpose of static keyword in Java?
The static keyword in Java is used to create class-level variables and methods that can be accessed without creating an instance of the class.
Static variables are shared among all instances of a class.
Static methods can be called without creating an instance of the class.
Static blocks are used to initialize static variables.
Static keyword can also be used to create static nested classes.
Q8. How can you create immutable class in Java?
Immutable class in Java cannot be modified after creation, ensuring data integrity.
Make the class final so it cannot be extended
Make all fields private and final so they cannot be modified
Do not provide setter methods, only getter methods to access the fields
If the class contains mutable objects, make sure to return a deep copy of them in getter methods
Q9. What is the use of final Keyword in Java?
The final keyword in Java is used to restrict the user from changing the value of a variable, making a method not overrideable, or making a class not inheritable.
Final variables cannot be reassigned once initialized.
Final methods cannot be overridden in subclasses.
Final classes cannot be extended by other classes.
Q10. Can a java class extend multiple classes?
No, a Java class cannot extend multiple classes.
Java does not support multiple inheritance for classes.
A class can only extend one other class, but can implement multiple interfaces.
Example: class MyClass extends ParentClass implements Interface1, Interface2
Q11. What is the default value of an int in Java?
The default value of an int in Java is 0.
In Java, when an int variable is declared but not initialized, it is automatically assigned the default value of 0.
For example, int num; // num is assigned the default value of 0.
Q12. There are three types of programming language. 1 - Hgh Level. 2 - Mid Level. 3 - Low Level.
High level languages are closer to human language, mid level languages are a mix of high and low level, and low level languages are closer to machine language.
High level languages are easier to read and write, like Java or Python.
Mid level languages provide a balance between high and low level, like C++.
Low level languages are closer to machine language, like Assembly.
Q13. The final keyword s used to declare: Final variables, Final methods and Final classes.
The final keyword is used to declare final variables, final methods, and final classes in Java.
Final variables cannot be reassigned once initialized.
Final methods cannot be overridden in subclasses.
Final classes cannot be extended.
Q14. How many types of programming languages?
There are three main types of programming languages: high-level, low-level, and middle-level.
High-level languages are closer to human language and easier to understand, like Java, Python, and Ruby.
Low-level languages are closer to machine language and harder to understand, like Assembly and Machine Code.
Middle-level languages, like C and C++, combine elements of both high-level and low-level languages.
Q15. ==compares object refrences (memory location). -equals() compares object values.
The difference between == and equals() in Java for comparing object references and values.
Use == to compare object references (memory location)
Use equals() to compare object values
Example: String str1 = new String("hello"); String str2 = new String("hello"); str1 == str2 will be false, but str1.equals(str2) will be true
Q16. What is the size of an int in Java?
The size of an int in Java is 4 bytes.
An int in Java is a 32-bit signed integer.
It can hold values ranging from -2,147,483,648 to 2,147,483,647.
The size of an int is fixed at 4 bytes on all platforms.
Q17. ==compares object references, while .equals() compares object values in java.
In Java, == compares object references, while .equals() compares object values.
Use == to compare if two object references point to the same memory location.
Use .equals() to compare if two objects have the same values.
Example: String str1 = new String("hello"); String str2 = new String("hello"); str1 == str2 will be false, but str1.equals(str2) will be true.
Q18. The size of an int in Java is 4 bytes (32bits).
Yes, the size of an int in Java is indeed 4 bytes (32 bits).
An int in Java can hold values ranging from -2,147,483,648 to 2,147,483,647.
The size of an int can be confirmed using the 'Integer.SIZE' constant in Java.
Using 'Integer.BYTES' will give the size of an int in bytes.
Q19. What is Java related framework?
Java related frameworks are tools that provide pre-written code to help developers build applications more efficiently.
Frameworks like Spring, Hibernate, and Struts are commonly used in Java development.
They provide libraries, APIs, and tools to simplify the development process.
Frameworks help with tasks like database access, security, and dependency injection.
Popular Java frameworks include Spring Boot, JavaServer Faces (JSF), and Apache Wicket.
Q20. What is JAVA Programming language?
JAVA is a high-level programming language known for its portability, security, and object-oriented features.
JAVA is platform-independent, meaning it can run on any device with a Java Virtual Machine (JVM)
It is object-oriented, allowing for modular and reusable code
JAVA is known for its security features, such as sandboxing and encryption
It is widely used for developing web applications, mobile apps, and enterprise software
Q21. What is the stands for JAVA?
Java stands for Just Another Virtual Machine
Java stands for Just Another Virtual Machine
It is a high-level programming language developed by Sun Microsystems
Java code is compiled into bytecode that runs on any Java Virtual Machine (JVM)
Q22. What is Java Language?
Java is a high-level, object-oriented programming language known for its portability and versatility.
Java is platform-independent, meaning it can run on any device with a Java Virtual Machine (JVM)
It is object-oriented, allowing for modular and reusable code
Java is known for its robust standard library, which includes tools for networking, data structures, and more
Q23. What is stands for JAVA?
JAVA stands for Java Virtual Machine
JAVA stands for Java Virtual Machine
It is a virtual machine that enables a computer to run Java programs
It provides a platform-independent execution environment for Java applications
Q24. What is the Java Language?
Java is a high-level programming language known for its portability, security, and object-oriented features.
Java is platform-independent, meaning it can run on any device with a Java Virtual Machine (JVM).
It is known for its robust security features, such as sandboxing and encryption.
Java is object-oriented, allowing for the creation of reusable code through classes and objects.
Q25. The default value of an int is 0.
Yes, the default value of an int in Java is 0.
In Java, when an int variable is declared but not initialized, it will have a default value of 0.
For example, int num; will have a default value of 0.
This default value is assigned by the Java Virtual Machine (JVM) when memory is allocated for the variable.
Q26. What is the Java?
Java is a high-level, object-oriented programming language known for its portability, security, and versatility.
Java is platform-independent, meaning it can run on any device with a Java Virtual Machine (JVM)
It is object-oriented, allowing for modular and reusable code
Java is known for its strong security features, such as sandboxing and encryption
Popular Java frameworks include Spring, Hibernate, and Apache Struts
Q27. Write a short java program to check if a number is prime.
Java program to check if a number is prime
Create a function that takes an integer as input
Check if the number is less than 2, return false
Iterate from 2 to the square root of the number, check for divisibility
If the number is divisible by any number, return false
Otherwise, return true
Q28. A prime number is a number greater than 1.....etc
A prime number is a number greater than 1 that can only be divided by 1 and itself.
Prime numbers are integers greater than 1
They have only two factors: 1 and the number itself
Examples of prime numbers: 2, 3, 5, 7, 11, 13
Q29. What is the difference between abstract class and an interface in Java?
Abstract class can have both abstract and non-abstract methods, while interface can only have abstract methods.
Abstract class can have constructors, member variables, and methods, while interface cannot.
A class can implement multiple interfaces but can only extend one abstract class.
Abstract classes are used to define a common behavior among subclasses, while interfaces are used to define a contract for classes to implement.
Example: Abstract class - Animal with abstract metho...read more
Q30. What is JVM in JAVA?
JVM stands for Java Virtual Machine, which is an abstract machine that enables a computer to run Java programs.
JVM is responsible for converting Java bytecode into machine code that can be executed by the computer's operating system.
It provides a platform-independent execution environment for Java programs.
JVM manages memory, handles garbage collection, and provides security features for Java applications.
Examples of JVM implementations include Oracle HotSpot, OpenJ9, and Gra...read more
Q31. An abstract class can have method implements and abstract method, while an interface only contains abstract method (before Java 8) . Abstract classes support single inheritance, whereas interfaces support multi...
read moreAbstract classes can have both implemented and abstract methods, while interfaces can only have abstract methods. Abstract classes support single inheritance, interfaces support multiple inheritance.
Abstract classes can have both implemented and abstract methods, providing more flexibility in design.
Interfaces can only have abstract methods, promoting a more strict contract for implementing classes.
Abstract classes support single inheritance, allowing for a hierarchical struc...read more
Interview Process at NISA Global
Top Java Developer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month