Back

Project Engineer

Questions

 219 Questions
Clicking on the following links will update the content below
Question 1 of 219

1. How will you write a program for circular linked list?


Overview

This question tests the applicant's knowledge of computer programming. It is a very common question for software engineers. The applicant should be able to write a program that uses a circular linked list.

Interview Expectations

Knowledge of computer programming
Knowledge of linked lists
Ability to write code

Sample Answer

I would first create a class called "CircularLinkedList" that contains two variables, "next" and "data". I would then create a constructor that accepts an integer and sets the "next" variable to null. I would then create a method called "insert" that accepts an integer and sets the "data" variable to the integer passed in. The method would then set the "next" variable to the value of the "next" variable plus one. I would then create a method called "getData" that returns the value of the data variable.