Interview Preparation (1/n)

BoredBlogger
4 min readJan 30, 2021

--

One of the dreaded parts for a software engineer is having to attend technical interviews. I know it first hand since I had to interview at multiple organizations before landing my current job. I have explained all the pain points in this post do give it a read. Recently I have started interviewing people for our organization. This change, helped me get a different perspective on:

  1. What interviewers are looking for in a candidate
  2. How the next question depends on your previous answer
  3. How you as a candidate can drive the interview instead of the interviewer

So when I was the candidate I would go through various websites which give interview questions in X language. Most of these websites fail to explain the concept in depth. Which is exactly what the interviewers are looking for!

The interviewers are looking for in-depth knowledge of ‘Basic’ concepts

It is important that you showcase an understanding of the concept and just not appear that you have memorized definitions. For people with experience, it is important to showcase that you have used these basic concepts and you know these concepts in depth.

Usually, the first interview question is “Tell us about yourself”. The reason for asking this question is twofold. The first and obvious one is to get to know about you and your professional experience. The second is to put the candidate at ease and make them comfortable.

Usually, one mistake candidates do while answering this question is that they start telling about the project in detail. Explaining in depth what the project was about but this doesn’t tell us about the candidate, it just explains his/her project. What we want to know are the below things:

  1. What is your contribution to this project?
  2. What were your role and responsibility?
  3. If you had faced any challenges and how you overcame those.

This gives us an idea about what technology you have worked on and gives slight clue about your expertise. This will give us an insight into what you know and what you might not know. This helps us in phrasing the next questions.

Let’s get straight into it.

1) What are the various OOPS concepts that you’ve used in your projects till now?

Pay attention to the phrasing of the question, it’s just not “explain about OOPS concepts” it’s asking you about the concept and also asking you to explain its practical applicability.

Answer: Objects and Classes are straightforward so I won’t b dwelling on that.

3. Inheritance: According to oracle documentation

The idea of inheritance is simple but powerful: When you want to create a new class and there is already a class that includes some of the code that you want, you can derive your new class from the existing class. In doing this, you can reuse the fields and methods of the existing class without having to write (and debug!) them yourself.

Explain this in your own words and think about a simple example that you can tell from your project. Abstract it out, don’t get into the nitty-gritty details of your project. Explain the concept and not your project.

Key properties to remember:

  • You can declare a field in the subclass with the same name as the one in the superclass, thus hiding it (not recommended).
  • You can write a new instance method in the subclass that has the same signature as the one in the superclass, thus overriding it.
  • You can write a new static method in the subclass that has the same signature as the one in the superclass, thus hiding it.
  • You can write a subclass constructor that invokes the constructor of the superclass, either implicitly or by using the keyword super.

The next question that would follow up with this would be what is overriding and hiding. The question would be making you write an example class for inheritance.

class A
{
public void display()
{
System.out.println("class A display");
}

public static void show()
{
System.out.println("class A show");
}
public void print()
{
System.out.println("class A print");
}
}class B extends A
{
public void display()
{
System.out.println("class B display");
}
public static void show()
{
System.out.println("class B show");
}
public int print()
{
System.out.println("class B print");
return 0;
}
}
public class MainClass{public static void main(String []args){

B b = new B();
A b1 = new B();
b.show();
b1.show();
b.display();
b1.display();
}
}

Other than the obvious questions, a few tricky ones would be :

  1. If function print is valid overriding?

Ans: No, returns type should also be the same. There is an exception when it comes to covariant return types. You can read more about it from here.

2. What will be the output of the above program?

class B show
class A show
class B display
class B display

--

--