Technical Interview Questions with a Checked OOP Example

Technical interview answers should explain the mechanism, its assumptions and the limit of the conclusion. The ten questions below cover HTTP and HTTPS, Java memory, REST, object-oriented programming, SQL, MVC, deadlocks and web security. A checked offline Python example demonstrates inherited interfaces and overridden methods, while the other answers distinguish language-specific behaviour from universal claims.

Jul 25, 2024 - 14:34
Updated: 
103.6k

Web & API Security in Cybersecurity & Ethical Hacking · Interview preparation

Technical Interview Questions with a Checked OOP Example

Quick answer: Technical interview answers should explain the mechanism, its assumptions and the limit of the conclusion. The ten questions below cover HTTP and HTTPS, Java memory, REST, object-oriented programming, SQL, MVC, deadlocks and web security. A checked offline Python example demonstrates inherited interfaces and overridden methods, while the other answers distinguish language-specific behaviour from universal claims. Use these as original practice questions, then prepare deeper examples for the technologies and tasks named in the actual role.

Key takeaways

  • Explain mechanisms instead of memorising definitions alone.
  • Separate transport protection from application trust.
  • Keep Java memory claims specific to the JVM.
  • Discuss query plans before promising index improvements.
  • Use language-appropriate examples of inheritance and dispatch.

Table of Contents

How do HTTP, HTTPS and REST differ?

1. What is the difference between HTTP and HTTPS? RFC 9110 specifies HTTP semantics. HTTPS uses a protected HTTP connection; RFC 8446 describes TLS 1.3 transport protections. Appropriate certificate validation and negotiated protection matter. HTTPS does not prove the site’s content is honest or that an application’s business permissions are correct.

2. What is a RESTful API? Fielding’s REST chapter defines architectural constraints including client-server, stateless interaction, caching, a uniform interface and layers. An HTTP endpoint returning JSON is not automatically fully RESTful. Stateless interaction does not mean the server cannot store resources; distinguish resource state from client session context.

A follow-up might ask whether a POST is safe to repeat after a timeout. Discuss the operation’s actual semantics and duplicate handling. A protected connection and an API style do not decide whether retrying a business action could create a second record.

What should you say about garbage collection and memory?

3. How does Java garbage collection work? The JVM manages heap storage automatically and can reclaim unreachable objects. Oracle’s Java SE 25 collector overview describes multiple collectors with different goals. Garbage collection does not eliminate memory leaks caused by retaining unwanted references, nor does it automatically release every external resource.

4. How do stack and heap memory differ? In the Java SE 25 JVM specification, each thread has a private JVM stack containing frames, while the heap is shared and holds class instances and arrays. Avoid calling all stack allocation “static” or declaring a universal size and speed ranking across languages and implementations.

ConcernAccurate distinctionAvoid
JVM stackPer-thread frames and execution dataEvery local value is stored identically in all languages
JVM heapShared object and array storageGarbage collection prevents all memory leaks
External resourceMay need explicit lifecycle managementUnreachable object means every resource closed

How do inheritance and polymorphism appear in checked code?

5. What is inheritance? A derived class can use or specialise behaviour from a base class. Python’s class tutorial explains attribute lookup and overriding. In the fixture, Rectangle and Triangle inherit Shape’s interface and provide their own area method. The input dimensions are trusted positive numbers; validation is outside this example.

6. What is polymorphism? The caller uses the same operation while the object’s implementation determines the behaviour. The loop below calls area on two different objects. Python also supports this style through compatible objects without requiring a shared base class; Java-style overload selection should not be generalised to every language.

class Shape:
    def area(self):
        raise NotImplementedError

class Rectangle(Shape):
    def __init__(self, width, height):
        self.width, self.height = width, height

    def area(self):
        return self.width * self.height

class Triangle(Shape):
    def __init__(self, base, height):
        self.base, self.height = base, height

    def area(self):
        return self.base * self.height / 2

shapes = [Rectangle(3, 2), Triangle(3, 2)]
assert [shape.area() for shape in shapes] == [6, 3]
for shape in shapes:
    print(f"{type(shape).__name__}: {shape.area():g}")

Expected output:

Rectangle: 6
Triangle: 3

This exact source and output were checked offline on Python 3.14.4. It demonstrates method dispatch and two area calculations, not geometry-input validation, a production plugin architecture or Java runtime execution.

How would you answer an SQL optimisation question?

7. How do you optimise an SQL query? First check required rows, joins, filters and ordering, then examine an appropriate plan and representative workload. PostgreSQL’s EXPLAIN guidance distinguishes estimates from actual execution evidence. EXPLAIN ANALYZE executes the statement, so its use requires suitable authority and a safe environment.

An index can help particular access patterns while adding storage and write costs. Selecting fewer columns can reduce transferred data, but it is not a universal cure for every slow query. The relevant result must remain correct after a change.

For a hypothetical report, ask whether joins multiply rows and whether a total is calculated at the intended level. A fast query returning duplicated totals is still wrong. No database query or plan was executed for this article.

What responsibilities does MVC separate?

8. What is Model-View-Controller? Microsoft’s ASP.NET Core MVC overview describes models for application state and business behaviour, views for presentation, and controllers for handling interaction and selecting results. This is one documented implementation context; not every framework uses identical details.

In a fictional inventory page, the model expresses the relevant stock rule, the controller handles the request and the view presents the result. Separating code into three folders does not guarantee the responsibilities are actually separated. A controller that embeds every business rule may still be difficult to test and maintain.

Ask where authorisation and transaction requirements are enforced in the chosen framework. MVC is an organisational pattern, not a substitute for those controls, and it does not automatically make an application scalable or secure.

How should you explain deadlock and its limits?

9. What is a deadlock? A set of activities cannot progress because each waits on a condition or resource held within the set. Oracle’s legacy Java tutorial illustrates mutually waiting threads. Its JDK 8 examples are historical teaching material, not current-release configuration instructions or executed code here.

For a simple two-lock scenario, one worker holds lock A and waits for B while another holds B and waits for A. Explain the resource ownership and waits. A consistent lock order can prevent that particular circular acquisition pattern when correctly applied; real systems may have additional resources and conditions.

Do not confuse deadlock with a slow task, starvation or a long but eventually completing wait. Obtain relevant evidence before diagnosing a production freeze, and avoid reproducing a deliberate hang on a live system.

Observation or designQuestion to askSupported limit
Two workers blockedWhich locks and waits exist?Blocking alone is not complete diagnosis
Consistent lock orderDoes every relevant path follow it?One reviewed path is insufficient
Retained objectsWhich references remain reachable?Not automatically a collector defect

How do you explain web security without a universal checklist claim?

10. How do you protect a web application? Define the relevant requirements and data flows. OWASP’s authorisation guidance calls for permission checks on the relevant request and resource. Safe query construction, contextual rendering, authentication, secret handling, updates and logging address different risks; input validation alone does not prevent every injection or permission defect.

If asked something unfamiliar, say what you know and which detail you would verify. Tie the answer to the actual technology and version rather than transplant a claim about Java memory into Python or assume every JSON endpoint satisfies REST.

For the checked shape fixture, be ready to explain why the two calls select different methods and what happens if the base implementation is called. Keep that small demonstration separate from claims about a full application or an unexecuted technology stack.

Related reading: IT technical breadth; algorithm interview practice.

References

Frequently Asked Questions

It protects the connection under its validation and protocol conditions, while application correctness, authorisation and the honesty of content remain separate concerns.

REST defines architectural constraints beyond a data format or transport, so evaluate the actual interaction rather than infer the style from JSON.

Unwanted objects can remain reachable through retained references, so automatic memory management does not eliminate every form of application memory retention.

Memory organisation and performance depend on the language and implementation, so describe the documented runtime model instead of asserting a universal ranking.

It checks two trusted-dimension area results and displays overridden method dispatch offline, without validating arbitrary inputs or executing Java code.

Its usefulness depends on the query, data, plan and workload, while extra indexes can also add storage and write costs.

It executes the statement to collect actual information, so use requires appropriate authority and a suitable environment for that execution.

It separates responsibilities in a documented design, while permission checks, data protection and other security requirements still need appropriate implementation and verification.

What's Your Reaction?

Like Like 0
Dislike Dislike 0
Love Love 0
Funny Funny 0
Wow Wow 0
Sad Sad 0
Angry Angry 0
Priyanka

I am dedicated to staying up-to-date on the most current technology trends and like to craft content that informs and inspires. Whether through detailed analysis, informative guides, or exact opinion articles, I desire to create engaging content for both technology lovers and industry experts.