Northcorp Software
40+ Altimetrik Interview Questions and Answers
Q1. 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
Q2. 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
Q3. What is the D/W Hashmap and ConcurrentHashmap in Java?
D/W Hashmap and ConcurrentHashmap are both implementations of the Map interface in Java, with the latter being thread-safe.
D/W Hashmap stands for 'Doubly-Linked Hashmap' and is a custom implementation of a hashmap in Java that maintains insertion order.
ConcurrentHashmap is a thread-safe implementation of the Map interface in Java, allowing multiple threads to access and modify it concurrently without causing data corruption.
Q4. What is the difference between HashMap and ConcurrentHashMap?
HashMap is not thread-safe and allows null keys/values, while ConcurrentHashMap is thread-safe and does not allow null keys/values.
HashMap is not thread-safe and can lead to ConcurrentModificationException if modified while iterating.
ConcurrentHashMap uses internal locking mechanisms to provide thread-safety.
ConcurrentHashMap does not allow null keys/values, while HashMap does.
ConcurrentHashMap is more suitable for concurrent operations compared to HashMap.
Q5. 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
Q6. 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.
Q7. == : 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.
Q8. 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.
Q9. ==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
Q10. What is the purpose of the volatile keyword?
The volatile keyword in Java is used to indicate that a variable's value will be modified by different threads.
Ensures visibility of changes made by one thread to other threads
Prevents compiler optimizations that could reorder instructions
Useful for variables accessed by multiple threads without synchronization
Example: volatile boolean flag = true;
Q11. 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
Q12. 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.
Q13. 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
Q14. 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.
Q15. 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
Q16. 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.
Q17. 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
Q18. 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.
Q19. 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.
Q20. Defining multiple methods with the same name but different parameters.
Method overloading allows defining multiple methods with the same name but different parameters.
Methods must have different parameter types or number of parameters.
Return type does not matter for method overloading.
Example: void print(int num) and void print(String text) are valid overloads.
Q21. HashMap is not thread-safe, while concurrentHashMap is thread-safe.
HashMap is not synchronized and not thread-safe, while ConcurrentHashMap is thread-safe and allows concurrent access.
HashMap is not synchronized, so it is not safe to use in a multi-threaded environment without external synchronization.
ConcurrentHashMap uses internal synchronization mechanisms to ensure thread safety, allowing multiple threads to access and modify it concurrently.
ConcurrentHashMap is designed to handle concurrent modifications without the need for external sy...read more
Q22. What is the role of a java developer?
A Java developer is responsible for designing, developing, and maintaining Java-based applications.
Designing and implementing Java applications
Writing efficient and maintainable code
Testing and debugging code
Collaborating with team members to solve technical problems
Keeping up-to-date with Java technologies and best practices
Q23. How does JVM optimize method calls?
JVM optimizes method calls using various techniques like inlining, escape analysis, and virtual method resolution.
JVM can inline methods by replacing the method call with the actual code, reducing overhead.
Escape analysis helps JVM determine if objects can be allocated on the stack instead of the heap.
Virtual method resolution optimizes method calls by caching the resolved method to avoid repeated lookups.
Q24. ==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
Q25. 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.
Q26. 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.
Q27. ==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.
Q28. 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.
Q29. 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.
Q30. 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
Q31. Develop, test and maintain java application.
Develop, test, and maintain Java applications to ensure functionality and performance.
Write clean and efficient code following best practices
Test the application thoroughly to identify and fix bugs
Regularly update and maintain the application to meet changing requirements
Q32. 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
Q33. 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)
Q34. What is method overloading?
Method overloading is when multiple methods in a class have the same name but different parameters.
Allows multiple methods with the same name but different parameters in a class
Parameters can differ in number, type, or order
Compile-time polymorphism
Example: void print(int a) and void print(String s)
Q35. What is JAVA Full Form?
JAVA stands for Java Virtual Machine
JAVA stands for Java Virtual Machine
It is a programming language that follows the principle of 'write once, run anywhere'
Java code is compiled into bytecode which can run on any platform with Java Virtual Machine (JVM)
Examples of Java applications include web applications, mobile apps, and enterprise software
Q36. What is inheritance in JAVA?
Inheritance in JAVA allows a class to inherit properties and behaviors from another class.
Allows a class to inherit fields and methods from another class
Promotes code reusability and reduces redundancy
Creates a parent-child relationship between classes
Example: class B extends class A
Q37. 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.
Q38. 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
Q39. 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
Q40. 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.
Q41. 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
Q42. 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
Q43. What is Java API?
Java API stands for Java Application Programming Interface, which provides a set of pre-written code for common tasks in Java programming.
Java API includes classes, interfaces, packages, and methods that developers can use to interact with the Java programming language.
It simplifies the development process by providing ready-to-use components for tasks like file handling, networking, database connectivity, and more.
Examples of Java API components include java.lang, java.util,...read more
Interview Process at Altimetrik
Top Java Developer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month