0% found this document useful (0 votes)
474 views19 pages

Thoughtworks: TR Interview:-Interview Experience 1 - (90 Mins On Zoom, 2 Interviewers)

The document discusses ThoughtWorks technical interviews and provides details on common questions asked. It describes five separate interview experiences, with questions covering algorithms and data structures, SQL, OOP concepts, databases, and systems design. Sample questions include implementing sorting algorithms, querying a database, explaining hashmaps, and designing schemas. The document also provides explanations of core Java concepts frequently tested, such as serialization, garbage collection, and threads.

Uploaded by

Aditya Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
474 views19 pages

Thoughtworks: TR Interview:-Interview Experience 1 - (90 Mins On Zoom, 2 Interviewers)

The document discusses ThoughtWorks technical interviews and provides details on common questions asked. It describes five separate interview experiences, with questions covering algorithms and data structures, SQL, OOP concepts, databases, and systems design. Sample questions include implementing sorting algorithms, querying a database, explaining hashmaps, and designing schemas. The document also provides explanations of core Java concepts frequently tested, such as serialization, garbage collection, and threads.

Uploaded by

Aditya Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 19

ThoughtWorks

TR Interview :-

Interview Experience 1 -> (90 mins on zoom, 2 interviewers)


 I got 5 programming questions of medium level one by one to solve
[ Practice Data Structures and Algorithms specially Arrays, Linked Lists,
Stack, Queues and Trees].
 After this they asked me, questions related to OOPs concepts like
polymorphism.
 Next, they asked me to write 4-5 queries in MySQL.
 Then asked me about my project.

Interview Experience 2 -> (2 hours)


 Explain Merge Sort and code on board and tell approach of Quick Sort
 Explain working of HashMap in depth
 Draw a Database table for Song app, they also asked to perform
Normalization(1NF, 2NF….BCNF) on tables and then they asked to write
queries.
 Tree traversals and Boundary Traversal
 Difference B/W Segmentation and Paging, Page Fault
 What is DNS Lookup, Load Balancer, and How Server works
 Polymorphism and types and their difference
 Questions on Project and their implementation
 DFS and BFS
and many more….

Interview Experience 3 ->


Some questions were:
 Given the address of a particular node. Delete that node in a Double
Linked List.
 Same question for a Circular Linked List.
 Given the address of a particular node but the address of the head is not
given. Delete that node in a Singly Linked List.
 How will you detect a loop in a Linked List?
 What is HashMap?
 Internal Workings of a HashMap?
 What is Hashing?
 What is Dynamic Programming?
 A program to find the different ways we can get a sum from the
elements of an array.
 What are the different Sorting Techniques?
 Time Complexity of Quick sort?
 Explain Quick Sort.
 Derive the time complexity of Quick sort.
 How will you distinguish between duplicate values in a Table.
 Write the QUERY to create a Table.
 What is the difference between varchar and varchar2?
 What is indexing?
 Disadvantages of Indexing?
 What are decorators?
 What are iterables?
 Mention the two main properties of iterables.
They also asked me some questions related to my Projects.

Interview Experience 4 -> (2 hours)


 Approx. 45 min discussion and explanation on projects and
internships(very thorough)
 Discussion about java garbage collector
 The bracket balancing problem
 Suppose there is a disk having concentric circular tracks. There are
sectors marked on the disk. We can add any number of tracks we want
and we can add sectors too. How can be
represented using data structures.
 Discussion on objects, their identity and difference between two objects
of the same class.
 Why should we use database when we can store data directly in server?
 Make the database schema of a bank
 Some SQL queries regarding this and discussion about keys
 Why do I find Java to be more advantageous than C++?

Interview Experience 5 ->


Technical interview 1
 Which language u prefer c or java? Why?
 Questions on project
 Write code for merge sort and simulate on array?
 Questions on collections java and implementation
 Explain Sudoku backtracking algorithm
 Design rat in maze problem in oops
 Design fan in oops
 Questions on hashing
 Osi model and function of each layer with some examples
 Database normalization explain 2nf 3nf bcnf with examples
 Schema design for students’ course and department and asked to write
some queries
Technical interview 2
 Features of java and when to use c instead of java
 Write code to reverse doubly linked list and simulate with examples
 Create tree form 2 traversals
 Code to detect loop in linked list and solution to remove it
 What happens when u type google.com
 Design student subject’s schema
 Questions on Array and Linked list and their usage
 Questions on implementation of Collections
 Questions on garbage collector in java
 Some questions on project
 Code for finding tree height ,diameter
Interview Experience 6 ->
 The interviewer started with the usual “Introduce Yourself”.
 He began questioning from my projects. An Android Project of mine
included a concept of JSON parsing and he asked me to JSON Model an
object.
 Then he asked to write xml for the same. He also asked to write the
logical code of another project .
 He asked to explain the concept of JVM, the byte code and the role of
archive files.
 To Display the even indexed numbers followed by the odd indexed
numbers reversely for an array of any size. Given , a[5] = {1,2,3,4,5} ;
(i.e.) 1,3,5,4,2.
 Next, I was asked to code for the Tic-Tac-Toe game! I gave him a solution
and he gave me few suggestions on how to make it more efficient. I tried
implementing those! We had a long discussion regarding the flow of the
algorithm and the concepts implemented.
 He then asked to implement the concept of polymorphism for a scenario
he provided in the language I was comfortable with. It was an easy one!

Content, Notes, Solution


JAVA :-

1. JVM and Bytecode ->


 JVM(Java Virtual Machine) – It acts as a run-time engine to run Java
applications. JVM is the one that actually calls the main method
present in a java code. It is also known as interpreter as it executes
the bytecode line by line. It is platform dependent, however Java is
platform independent language(WORA -> Write Once, Run
Anywhere).
 (JRE)Java Runtime Environment – It provides the requirements for
executing a java application at runtime. It includes of JVM and other
supporting files.
 JDK(Java Development Kit) – It is complete software development
environment. It includes JRE, an interpreter(JVM), a compiler(javac),
an archiver(jar) and other development tools.
JAR stands for Java ARchive. It's a file format based on the popular ZIP file
format and is used for aggregating many files into one. It is a file that
contains a compressed version of .class files, audio files, image files, or
directories. It is mostly used for supplying the necessary Java libraries and
application software on a Java programming platform.
Bytecode - Bytecode in Java is an intermediate machine-independent code.
It is the compiled format for Java programs. In general, bytecode is a code
that lies between low-level and high-level language. The bytecode is not
processed by the processor but by JVM.
2. Unicode -> Encoding to represent text. Uses hexadecimal to express
characters. Requires 2Bytes (16-bit) for representing a character.

3. Serialization -> conversion of the state of an object into a byte stream


(which is platform independent).

Need - Serialization is usually used when the need arises to send your
data over network or stored in files. By data I mean objects and not text.
Now the problem is your Network infrastructure, and your Hard disk are
hardware components that understand bits and bytes but not JAVA
objects. Serialization is the translation of your Java object's values/states
to bytes to send it over network or save it.

How to do – (Don’t focus on code if you don’t want to, only go through
it if you have time)
Step1. Class must implement the interface java.io.Serializable in
order for its object to get serialized.
Step 2. Use write Object() method to save serialized object in file.

Figure 1. Suppose we want to serialize an object of Demo class


Figure 2. Serialization

4. Deserialization :- Byte stream is used to recreate the actual Java object


in memory. Reverse of Serialization.

Figure 3. Deserialization

5. Wrapper Class :- It is a class whose objects wraps the primitive data


type. Means it converts primitive data types to objects.
Need –
 Data structures in the Collection framework, such as ArrayList and
Vector, store only objects (reference types) and not primitive types.
 An object is needed to support synchronization in multithreading.

Autoboxing: Automatic conversion of primitive types to the object of their


corresponding wrapper classes is known as autoboxing.

Unboxing: Automatically converting an object of a wrapper class to its


corresponding primitive type is known as unboxing.
6. Iterables :- It is an interface. An iterable interface allows an object to be
iterated or loop over using enhanced for-loop(for-each loop) or iterator
object.

Figure 4. Using enhanced for-loop

Figure 5. Using iterator object


7. Garbage Collection :- Garbage collection in Java is the process by which
Java programs perform automatic memory management. It deletes
unreachable, un-necessary objects to free heap memory. It is daemon
thread.
We can request JVM to run Garbage Collector by calling these methods :
(i). System.gc()
(ii). Runtime.getRuntime().gc()
Just before deleting an object, Garbage Collector calls finalize() method
on that object. It is called by GC and not JVM.

8. Daemon Thread :- It is a low priority thread, that runs in background to


perform tasks such as garbage collection.
It provides services to the user thread. Its life depends on the mercy of
user threads i.e., when all the user threads die, JVM terminates the
Daemon thread automatically.

Figure 6. Creating a Daemon Thread

Note :- If you call the setDaemon() method after starting the thread, it will
throw IllegalThreadStateException.
9. Threads :- These are light-weight processes within a process.
Thread Priority -> Default priority of main thread is 5. Priority ranges
from 1 to 10.
t.getPriority() -> to get priority of thread t1.
t1.setPriority(3) -> to set priority of thread t1 to 3.
Threads can be created by using two mechanisms :
(i). Extending the Thread class
We create a class that extends the java.lang.Thread class. This class
overrides the run() method available in the Thread class. A thread begins
its life inside run() method.

Output ->

Figure 7. Creation of Thread using extends

(ii). Implementing the Runnable Interface


We create a new class which implements java.lang.Runnable interface
and override run() method. Then we instantiate a Thread object and call
start() method on this object.
Output ->

Figure 8. Creation of Thread using runnable

Note:- A one-liner and elegant way for creating threads.

Output ->
Figure 9. Creating thread using lambda function. No need to extend or implement anything to the class.
10. Hashing in Java :- In hashing there is a hash function that maps keys to
some values. But these hashing function may lead to collision that is two
or more keys are mapped to same value.

HashMap ->
 HashMap<K, V> is a part of Java’s collection. It stores the data in
(Key, Value) pairs.
 It allows to store the null keys, but there should be only one null
key and there can be any number of null values.
 It implements Map interface.
 It is unsynchronized.

Implementation ->
Working of HashMap – (V. V. Important)

Reference : GeeksForGeeks (HashMap Working), Youtube - HashMap


Working

LinkedHashMap -> Keys are maintained by insertion order, i.e. they are
stored, in the order they are inserted. O(1) for lookup and insertion. It may
have one null key and multiple null values.

TreeMap -> Keys are stored in sorted order. It can’t have null keys but can
have multiple null values. So, if you want to sort the keys of a HashMap just
convert it to TreeMap.

11. When to use C over Java?


 C is a low-level programming language that is more close to system that
gives more freedom to a programmer, and adds very less complexity.
 Apart from this, pointer in C, makes it very rich, and gives very
advancement to programmer, that can be used to make very efficient
program.
So, whenever you want to interact with system (memory, registers, etc)
directly, use C or if you want more control over the program especially
memory management or want fast program execution, then C is your
altar.

12. Abstract class vs Interfaces :-


 Interface provides 100% abstraction while abstract class between
0 to 100%.
 Use abstract class when you have to provide some common
functionalities to the child classes. Like in case of banks, every
bank has same logic for withdraw, deposit money and there might
be some functions that differ, but at least many are same.

Figure 10. Abstract class


 Use interfaces when we just want to give child classes, some set of
contracts to must implement the methods. Here methods might be
same but the logic inside them differs in most of the child class
implementation.

13. Stream :- It is a sequence of data.

map: The map method is used to returns a stream consisting of the


results of applying the given function to the elements of this stream.

filter: The filter method is used to select elements as per condition from
the stream.
forEach: The forEach method is used to iterate through every element of
the stream.

reduce: The reduce method is used to reduce the elements of a stream


to a single value.
14.Character class :-
15. Common Utilities :-

You might also like