Add office photos
Engaged Employer

Cross Country Infotech

3.3
based on 73 Reviews
Filter interviews by

20+ Starwalk Services Interview Questions and Answers

Updated 5 Feb 2024

Q1. Do you have any Java certficate? If no then please leave you are rejected.

Ans.

Java certification is not mandatory for a Java Developer role.

  • Certification is not a measure of practical skills and experience.

  • Experience and skills are more important than certification.

  • Certification can be helpful in some cases, but not mandatory.

  • Certification can be expensive and time-consuming.

  • Employers may value certification differently.

  • Examples of Java certifications: Oracle Certified Professional Java SE 11 Developer, Java SE 8 Programmer, etc.

Add your answer

Q2. 9. When is memory allocated, when class is created or instance is created or when it is?

Ans.

Memory is allocated when an instance of a class is created.

  • Memory allocation happens when an object is created using the 'new' keyword.

  • Static variables are allocated memory when the class is loaded.

  • Memory is released when the object is no longer referenced or when the program terminates.

Add your answer

Q3. 13. Other than inheritance what you will use to connect two classes?

Ans.

We can use composition, aggregation, or association to connect two classes.

  • Composition is a strong form of aggregation where the lifetime of the contained object is controlled by the container object.

  • Aggregation is a weaker form of composition where the contained object has an independent lifecycle.

  • Association is a relationship between two classes where one class uses the functionality of another class.

  • Examples of association are dependency, inheritance, and realization.

  • Examp...read more

Add your answer

Q4. 14. What are different types of Access Modifiers in Java?

Ans.

Access modifiers in Java are used to set the accessibility of classes, methods, and variables.

  • There are four types of access modifiers in Java: public, private, protected, and default.

  • Public: accessible from anywhere in the program.

  • Private: accessible only within the same class.

  • Protected: accessible within the same class, same package, and subclasses.

  • Default: accessible within the same package only.

Add your answer
Discover Starwalk Services interview dos and don'ts from real experiences

Q5. 3. What is difference between Abstract class and Interface.

Ans.

Abstract class can have implementation while interface cannot. A class can implement multiple interfaces but can only extend one abstract class.

  • Abstract class can have constructors while interface cannot.

  • Abstract class can have instance variables while interface cannot.

  • Abstract class can have non-abstract methods while interface can only have abstract methods.

  • A class can implement multiple interfaces but can only extend one abstract class.

  • Abstract classes are used when there ...read more

Add your answer

Q6. 5. What is difference between composition and inheritance

Ans.

Composition is a way to combine objects to create complex structures, while inheritance is a way to create new classes based on existing ones.

  • Composition is a 'has-a' relationship, where an object contains other objects as its parts.

  • Inheritance is an 'is-a' relationship, where a subclass inherits properties and behaviors from its superclass.

  • Composition allows for greater flexibility and modularity in design, as objects can be easily swapped out or added.

  • Inheritance can lead t...read more

Add your answer
Are these interview questions helpful?

Q7. 20. What are different types of collections?

Ans.

Collections are used to store and manipulate groups of objects in Java. There are three main types of collections.

  • The three main types of collections are List, Set, and Map.

  • List is an ordered collection that allows duplicates. Example: ArrayList.

  • Set is an unordered collection that does not allow duplicates. Example: HashSet.

  • Map is a collection that maps keys to values and does not allow duplicate keys. Example: HashMap.

Add your answer

Q8. 7. What is difference between throw and throws

Ans.

throw is used to explicitly throw an exception while throws is used to declare an exception that a method may throw.

  • throw is used within a method to throw an exception when a certain condition is met

  • throws is used in the method signature to declare the exceptions that the method may throw

  • throw is followed by an instance of an exception class while throws is followed by the name of the exception class

  • throw is used to handle exceptions within a method while throws is used to pr...read more

Add your answer
Share interview questions and help millions of jobseekers 🌟

Q9. 17. Can subclass inherit the properties of Parent class if we not load parent class

Ans.

No, subclass cannot inherit properties of parent class if parent class is not loaded.

  • In order for a subclass to inherit properties of a parent class, the parent class must be loaded.

  • If the parent class is not loaded, the subclass will not have access to its properties.

  • This is because inheritance is a compile-time concept and requires the parent class to be present during compilation.

  • Attempting to access properties of an unloaded parent class will result in a compilation error...read more

Add your answer

Q10. 16. Can subclass access private methods parent class?

Ans.

No, subclass cannot access private methods of parent class.

  • Private methods are only accessible within the same class where they are defined.

  • Subclasses can access protected and public methods of parent class.

  • Private methods can be accessed indirectly through public or protected methods of parent class.

Add your answer

Q11. 10. What is stack in programming?

Ans.

A stack is a data structure that follows the Last In First Out (LIFO) principle.

  • Elements are added and removed from the top of the stack.

  • Push() adds an element to the top of the stack.

  • Pop() removes the top element from the stack.

  • Peek() returns the top element without removing it.

  • Used in programming for function calls, expression evaluation, and memory management.

Add your answer

Q12. 11. What is queue in programming?

Ans.

A queue is a data structure that follows the FIFO (First In First Out) principle.

  • Elements are added to the back of the queue and removed from the front.

  • Common operations include enqueue (add to back) and dequeue (remove from front).

  • Examples include a line of people waiting for a movie or a printer queue.

  • Java provides the Queue interface and its implementations like LinkedList and PriorityQueue.

Add your answer

Q13. 2. Give me Real life example of Polymorphism

Ans.

Polymorphism is when an object can take on multiple forms and behave differently based on the context.

  • A car can be a vehicle, but it can also be a sports car or a family car, each with different behaviors.

  • A shape can be a square, rectangle, or triangle, each with different methods for calculating area and perimeter.

  • A media player can play different types of media, such as audio or video, each with different playback controls.

Add your answer

Q14. 4. Can we have multi level inheritance in Java

Ans.

Yes, Java supports multi level inheritance.

  • Multi level inheritance is the process of inheriting a class from another derived class.

  • It helps in creating a hierarchy of classes with each level inheriting properties from the previous level.

  • For example, class C can inherit from class B, which in turn inherits from class A.

  • Java does not support multiple inheritance, where a class can inherit from multiple classes at the same level.

Add your answer

Q15. 12. Difference between error and exception

Ans.

Errors are unrecoverable, while exceptions are recoverable.

  • Errors are caused by the environment in which the application is running, while exceptions are caused by the application itself.

  • Errors cannot be handled by the application, while exceptions can be handled using try-catch blocks.

  • Examples of errors include OutOfMemoryError and StackOverflowError, while examples of exceptions include NullPointerException and ArrayIndexOutOfBoundsException.

Add your answer

Q16. 1. What are four pillars of OOPS ?

Ans.

The four pillars of OOPS are Abstraction, Encapsulation, Inheritance, and Polymorphism.

  • Abstraction: Hiding implementation details and showing only necessary information.

  • Encapsulation: Binding data and methods together to protect data from outside interference.

  • Inheritance: Creating new classes from existing ones, inheriting properties and methods.

  • Polymorphism: Ability of objects to take on multiple forms or behaviors.

Add your answer

Q17. 21. Difference between array and heap?

Ans.

Arrays are fixed in size and stored in stack memory, while heap is dynamic and stored in heap memory.

  • Arrays are declared with a fixed size, while heap can grow or shrink dynamically.

  • Arrays are stored in stack memory, while heap is stored in heap memory.

  • Arrays can only store elements of the same data type, while heap can store objects of different types.

  • Examples of arrays include int[], char[], and String[], while examples of heap objects include ArrayList, HashMap, and Linked...read more

Add your answer

Q18. 22. Can we add duplicates to Set?

Ans.

No, Set does not allow duplicates.

  • Set is a collection that does not allow duplicates.

  • If you try to add a duplicate element to a Set, it will not be added.

  • You can use a List if you need to allow duplicates.

Add your answer

Q19. 23. Can we add duplicates to Array?

Ans.

Yes, duplicates can be added to an array.

  • Arrays in Java can contain duplicate elements.

  • Duplicate elements can be added to an array using the add() method of ArrayList class.

  • For example, int[] arr = {1, 2, 3, 3, 4}; or ArrayList list = new ArrayList<>(Arrays.asList(1, 2, 3, 3, 4));

Add your answer

Q20. 15. What is protected ?

Ans.

protected is a Java access modifier that allows access within the same package and subclasses.

  • Protected members can be accessed within the same package and subclasses.

  • It is used to provide encapsulation and prevent direct access from outside the class.

  • Protected members can be accessed using the dot operator.

  • Example: protected int num; can be accessed in a subclass using obj.num;

Add your answer

Q21. 19. What are collections?

Ans.

Collections are objects that group multiple elements into a single unit.

  • Collections are used to store, retrieve, manipulate and communicate aggregate data.

  • Java provides a set of interfaces and classes that implement various types of collections.

  • Examples of collections include List, Set, Map, Queue, etc.

  • Collections can be used to improve code readability, reusability, and performance.

Add your answer

Q22. 8. Can we have multiple try block

Ans.

Yes, we can have multiple try blocks in Java.

  • Multiple try blocks can be used to handle different exceptions separately.

  • Each try block must have at least one catch or finally block.

  • Nested try blocks can also be used.

  • Example: try { //code } catch (Exception e) { //code } try { //code } catch (IOException e) { //code }

  • Example of nested try blocks: try { try { //code } catch (Exception e) { //code } } catch (Exception e) { //code }

Add your answer

Q23. 6. What is exception handing

Ans.

Exception handling is the process of handling errors and exceptions that occur during program execution.

  • Exceptions are objects that represent errors or exceptional situations that occur during program execution.

  • Exception handling involves catching and handling these exceptions to prevent program crashes.

  • Java provides try-catch-finally blocks for handling exceptions.

  • Examples of exceptions include NullPointerException, ArrayIndexOutOfBoundsException, and FileNotFoundException.

Add your answer

Q24. 18. Can class be private?

Ans.

Yes, a class can be private in Java.

  • A private class can only be accessed within the same outer class.

  • It cannot be accessed from outside the class or even from subclasses.

  • Private classes are often used for implementation details that should not be exposed to other classes.

  • Example: private class Node in a LinkedList implementation.

Add your answer
Contribute & help others!
Write a review
Share interview
Contribute salary
Add office photos

Interview Process at Starwalk Services

based on 1 interviews
Interview experience
1.0
Bad
View more
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Java Developer Interview Questions from Similar Companies

3.8
 • 45 Interview Questions
4.4
 • 42 Interview Questions
3.5
 • 19 Interview Questions
3.8
 • 13 Interview Questions
3.6
 • 10 Interview Questions
3.6
 • 10 Interview Questions
View all
Share an Interview
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
70 Lakh+

Reviews

5 Lakh+

Interviews

4 Crore+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter