Top Computer Science Interview Questions

What is a process?

A process is an instance of a program in execution. For example, a Web Browser is a process, and a shell (or command prompt) is a process.

What is a Process Table?

To keep track of the state of all the processes, the operating system maintains a table known as the process table.

What are the different states of the process?

  • New − The process is being created.
  • Running − In this state the instructions are being executed.
  • Waiting − The process is in waiting state until an event occurs like I/O operation completion or receiving a signal.
  • Ready − The process is waiting to be assigned to a processor.
  • Terminated − the process has finished execution.

What is PCB?

The process control block (PCB) is a block that is used to track the process’s execution status. A process control block (PCB) contains information about the process, i.e. registers, quantum, priority, etc. The process table is an array of PCBs, that means logically contains a PCB for all of the current processes in the system.

What is a Thread?

A thread is a single sequence stream within a process.

What are Process Schedulers in OS (Operating System)?

Operating system uses various schedulers for the process scheduling described below.

Long term scheduler:

Long term scheduler is also known as job scheduler. It chooses the processes from the pool (secondary memory) and keeps them in the ready queue maintained in the primary memory.

Short term scheduler:

Short term scheduler is also known as CPU scheduler. It selects one of the Jobs from the ready queue and dispatch to the CPU for the execution.

Medium term scheduler:

Medium term scheduler takes care of the swapped out processes. If the running state processes needs some IO time for the completion then there is a need to change its state from running to waiting.

What is Thrashing?

Thrashing is a situation when the performance of a computer degrades or collapses. Thrashing occurs when a system spends more time processing page faults than executing transactions. Thrashing is a phenomenon in virtual memory scheme when the processor spends most of its time in swapping pages, rather than executing instructions.

What is Buffer?

A buffer is a memory area that stores data being transferred between two devices or between a device and an application.

What is the basic function of paging?

Paging is a method or technique which is used for non-contiguous memory allocation. It is a fixed-size partitioning theme (scheme). In paging, both main memory and secondary memory are divided into equal fixed-size partitions. The partitions of the secondary memory area unit and the main memory area unit are known as pages and frames respectively. Paging is used to solve the external fragmentation problem in operating system. This technique ensures that the data you need is available as quickly as possible.

Paging is a memory management method accustomed fetches processes from the secondary memory into the main memory in the form of pages. in paging, each process is split into parts wherever the size of every part is the same as the page size. The size of the last half could also be but the page size. The pages of the process area unit hold on within the frames of main memory relying upon their accessibility

What is demand paging?

The process of loading the page into memory on demand (whenever a page fault occurs) is known as demand paging. Demand paging specifies that if an area of memory is not currently being used, it is swapped to disk to make room for an application’s need.

What are the different scheduling algorithms?

  • First-Come, First-Served (FCFS) Scheduling.
  • Shortest-Job-Next (SJN) Scheduling.
  • Priority Scheduling.
  • Shortest Remaining Time.
  • Round Robin(RR) Scheduling.
  • Multiple-Level Queues Scheduling.

Banker’s Algorithm?

It is a banker algorithm used to avoid deadlock and allocate resources safely to each process in the computer system. Banker’s algorithm is used to avoid deadlock. It is the one of deadlock-avoidance method. It is named as Banker’s algorithm on the banking system where bank never allocates available cash in such a manner that it can no longer satisfy the requirements of all of its customers.

What is Fragmentation?

It is unused space of memory due to unequal size of memory. Fragmentation is a phenomenon of memory wastage. It reduces the capacity and performance because space is used inefficiently.

There are two types of fragmentation:

Internal Fragmentation: It is occurred when we deal with the systems that have fixed size allocation units.

External Fragmentation: It is occurred when we deal with systems that have variable-size allocation units.

What are types of Process Scheduling Techniques in Operating Systems?

The types of Process Scheduling Techniques in Operating Systems are:

  • Pre Emptive Process Scheduling
  • Non Pre Emptive Process Scheduling

What is the difference between preemptive and non-preemptive scheduling?

  • In preemptive scheduling, the CPU is allocated to the processes for a limited time whereas, in Non-preemptive scheduling, the CPU is allocated to the process till it terminates or switches to waiting for the state.
  • The executing process in preemptive scheduling is interrupted in the middle of execution when a higher priority one comes whereas, the executing process in non-preemptive scheduling is not interrupted in the middle of execution and waits till its execution.
  • In Preemptive Scheduling, there is the overhead of switching the process from the ready state to the running state, vice-verse, and maintaining the ready queue. Whereas the case of non-preemptive scheduling has no overhead of switching the process from running state to ready state.
  • In preemptive scheduling, if a high-priority process frequently arrives in the ready queue then the process with low priority has to wait for a long, and it may have to starve. On the other hand, in non-preemptive scheduling, if CPU is allocated to the process having a larger burst time then the processes with a small burst time may have to starve.
  • Preemptive scheduling attains flexibility by allowing the critical processes to access the CPU as they arrive in the ready queue, no matter what process is executing currently. Non-preemptive scheduling is called rigid as even if a critical process enters the ready queue the process running CPU is not disturbed.
  • Preemptive Scheduling has to maintain the integrity of shared data that’s why it is cost associative which is not the case with Non-preemptive Scheduling.

What is the zombie process?

A process that has finished the execution but still has an entry in the process table to report to its parent process is known as a zombie process. A child process always first becomes a zombie before being removed from the process table. The parent process reads the exit status of the child process which reaps off the child process entry from the process table.

What are orphan processes?

A process whose parent process no more exists i.e. either finished or terminated without waiting for its child process to terminate is called an orphan process.

What are Starvation and Aging?

Starvation: Starvation is a resource management problem where a process does not get the resources it needs for a long time because the resources are being allocated to other processes.

Aging: Aging is a technique to avoid starvation in a scheduling system. It works by adding an aging factor to the priority of each request. The aging factor must increase the priority of the request as time passes and must ensure that a request will eventually be the highest priority request

 What is a Kernel?

A kernel is the central component of an operating system that manages the operations of computers and hardware.

What is Monolithic Kernel?

A monolithic kernel is an operating system kernel in which all the operating system services run in kernel space.

What is Micro Kernel?

A Micro kernel is a type of operating system kernel in which only the most basic services run in kernel space, with other services running in user space.

What is the difference between Micro Kernel and Macro Kernel?

Micro kernel: micro kernel is the kernel which runs minimal performance affecting services for operating system. In micro kernel operating system all other operations are performed by processor.

Macro Kernel: Macro Kernel is a combination of micro and monolithic kernel.

What is a System Call in Operating Systems?

Programs can communicate with the operating system by making a system call. When a computer application requests anything from the kernel of the operating system, it performs a system call. System call uses Application Programming Interfaces(API) to deliver operating system services to user programs

What is Inter-process communication (IPC)?

Inter-process communication (IPC) is a mechanism that allows processes to communicate with each other and synchronize their actions. The communication between these processes can be seen as a method of cooperation between them.

What is the Time-Sharing System?

Time-sharing is a logical extension of multiprogramming. The CPU performs many tasks by switches that are so frequent that the user can interact with each program while it is running.

What is Critical Section?

A critical section refers to a segment of code that is executed by multiple concurrent threads or processes, and which accesses shared resources. These resources may include shared memory, files, or other system resources that can only be accessed by one thread or process at a time to avoid data inconsistency or race conditions. When more than one process try to access the same code segment that segment is known as the critical section.

What is Context Switching?

Switching of CPU to another process means saving the state of the old process and loading the saved state for the new process. In Context Switching the process is stored in the Process Control Block to serve the new process so that the old process can be resumed from the same part it was left.

What is Semaphore?

Semaphore is a protected variable or abstract data type that is used to lock the resource being used. The value of the semaphore indicates the status of a common resource.

What is a Deadlock?

Deadlock occurs when each process holds a resource and wait for other resource held by any other process. Deadlock is a situation when two or more processes wait for each other to finish and none of them ever finish.  Consider an example when two trains are coming toward each other on the same track and there is only one track, none of the trains can move once they are in front of each other.  A similar situation occurs in operating systems when there are two or more processes that hold some resources and wait for resources held by other(s).

What are the necessary conditions which can lead to a deadlock in a system?

Mutual Exclusion: There is a resource that cannot be shared.

Hold and Wait: A process is holding at least one resource and waiting for another resource, which is with some other process.

No Preemption: The operating system is not allowed to take a resource back from a process until the process gives it back.

Circular Wait:  A set of processes waiting for each other in circular form.

What is Starvation?

Starvation is the problem that occurs when high priority processes keep executing and low priority processes get blocked for indefinite time. In heavily loaded computer system, a steady stream of higher-priority processes can prevent a low-priority process from ever getting the CPU. In starvation resources are continuously utilized by high priority processes. Problem of starvation can be resolved using Aging. In Aging priority of long waiting processes is gradually increased.

Write a difference between Paging and Segmentation?

In paging, program is divided into fixed or mounted-size pages.

In segmentation, the program is divided into variable-size sections.

What is a socket?

A socket is used to make connection between two applications. Endpoints of the connection are called socket.

What are the main features of OOPs?

The main feature of the OOPs, also known as 4 pillars or basic principles of OOPs are as follows:

  • Encapsulation
  • Data Abstraction
  • Polymorphism
  • Inheritance

JAVA, C++, Python are OOPs languages

What is Polymorphism?

Polymorphism refers to the ability to exist in multiple forms. Multiple definitions can be given to a single interface. For example, if you have a class named Vehicle, it can have a method named speed but you cannot define it because different vehicles have different speed. This method will be defined in the subclasses with different definitions for different vehicles.

What is Key Differences Between Errors and Exceptions?

Errors indicate unrecoverable system issues beyond program control. In contrast, exceptions represent unexpected events within the program that can often be handled gracefully.

What is Garbage Collection(GC)?

GC is an implementation of automatic memory management. The Garbage collector frees up space occupied by objects that are no longer in existence.

What is Dangling Pointer?

Dangling pointers arise during object destruction, when an object that has an incoming reference is deleted or deallocated, without modifying the value of the pointer, so that the pointer still points to the memory location of the deallocated memory.

Differentiate between an abstract class and an interface?

Abstract Class Can have abstract as well as other methods.

Interface has Only abstract methods.

What are Virtual Functions?

Virtual functions are functions that are present in the parent class and are overridden by the subclass. These functions are used to achieve runtime polymorphism.

A pure virtual function, also known as an abstract function is a member function that doesn’t contain any statements. This function is defined in the derived class if needed.

Example:

class base {

virtual void pureVirFunc() = 0;

}

What are Pure Virtual Functions?

Pure virtual functions or abstract functions are functions that are only declared in the base class. This means that they do not contain any definition in the base class and need to be redefined in the subclass.

What are super, primary, candidate, and foreign keys?

A super key is a set of attributes of a relation schema upon which all attributes of the schema are functionally dependent. No two rows can have the same value of super key attributes.

A Candidate key is a minimal superkey, i.e., no proper subset of Candidate key attributes can be a superkey.

A Primary Key is one of the candidate keys. One of the candidate keys is selected as most important and becomes the primary key. There cannot be more than one primary key in a table..

A Foreign key is a field (or collection of fields) in one table that uniquely identifies a row of another table.

What are the differences between DDL, DML, and DCL in SQL?

Following are some details of three :

DDL stands for Data Definition Language. SQL queries like CREATE, ALTER, DROP, TRUNCATE and RENAME come under this.

DML stands for Data Manipulation Language. SQL queries like SELECT, INSERT, DELETE and UPDATE come under this.

DCL stands for Data Control Language. SQL queries like GRANT and REVOKE come under this.

What is a Trigger?

A Trigger is a code associated with insert, update or delete operations. The code is executed automatically whenever the associated query is executed on a table. Triggers can be useful to maintain integrity in the database.

What is a Stored Procedure?

A stored procedure is like a function that contains a set of operations compiled together. It contains a set of operations that are commonly used in an application to do some common database tasks.

What is the difference between Trigger and Stored Procedure?

Unlike Stored Procedures, Triggers cannot be called directly. They can only be associated with queries.

What is a transaction? What are ACID properties?

A Database Transaction is a set of database operations that must be treated as a whole, which means either all operations are executed or none of them. An example can be a bank transaction from one account to another account. Either both debit and credit operations must be executed or none of them. ACID (Atomicity, Consistency, Isolation, Durability) is a set of properties that guarantee that database transactions are processed reliably.

What are Indexes?

A database index is a data structure that improves the speed of data retrieval operations on a database table at the cost of additional writes and the use of more storage space to maintain the extra copy of data. Data can be stored only in one order on a disk. To support faster access according to different values, faster search like binary search for different values is desired, For this purpose, indexes are created on tables. These indexes need extra space on the disk, but they allow faster search according to different frequently searched values.

What are clustered and non-clustered Indexes?

Clustered indexes are the index according to which data is physically stored on a disk. Therefore, only one clustered index can be created on a given database table.

Non-clustered indexes don’t define the physical ordering of data, but logical ordering. Typically, a tree is created whose leaf point to disk records. B-Tree or B+ tree are used for this purpose.

What is 1NF in the DBMS?

1NF is known as the First Normal Form:

This is the easiest form of the normalization process which states that the domain of an attribute should have only atomic values. The objective of this is to remove the duplicate columns that are present in the table.

What is 2NF in the DBMS?

2NF is the Second Normal Form.

Any table is said to have in the 2NF if it satisfies the following 2 conditions:

A table is in the 1NF.

Each non-prime attribute of a table is said to be functionally dependent in totality on the primary key.

What is 3NF in the DBMS?

3NF is the Third Normal Form.

Any table is said to have in the 3NF if it satisfies the following 2 conditions:

A table is in the 2NF.

Each non-prime attribute of a table is said to be non-transitively dependent on every key of the table.

What is BCNF in the DBMS?

BCNF is the Boyce Codd Normal Form which is stricter than the 3NF.

Any table is said to have in the BCNF if it satisfies the following 2 conditions:

A table is in the 3NF.

For each of the functional dependencies X->Y that exists, X is the super key of a table.

What is the main goal of RAID technology?

RAID stands for Redundant Array of Inexpensive (or sometimes “Independent”)Disks.

RAID is a method of combining several hard disk drives into one logical unit (two or more disks grouped together to appear as a single device to the host system). RAID technology was developed to address the fault-tolerance and performance limitations of conventional disk storage. It can offer fault tolerance and higher throughput levels than a single hard drive or group of independent hard drives. While arrays were once considered complex and relatively specialized storage solutions, today they are easy to use and essential for a broad spectrum of client/server applications.

What is a Network Protocol?

A network protocol is a set of rules and conventions for communication between network devices..

Define network topology.

Network topology refers to the network’s physical structure that defines how nodes or computers will be connected.

Network Topologies are Bus, Star, Ring, Mess, Tree, Hybrid.

What is a firewall?

A firewall is a security system concept that helps in protecting computers from any cyber-attack or unauthorized access.

How many layers are there under TCP/IP?

There are four layers:

  • The Network Layer
  • Internet Layer
  • Transport Layer
  • Application Layer.

What are proxy servers, and how do they protect computer networks?

Proxy servers primarily prevent external users who are identifying the IP addresses of an internal network. Without knowledge of the correct IP address, even the physical location of the network cannot be identified. Proxy servers can make a network virtually invisible to external users.

What are gateways?

Gateways provide connectivity between two or more network segments

What is Ping?

Ping is a utility program that allows you to check connectivity between network devices on the network. You can ping a device by using its IP address or device name, such as a computer name.

What is Domain Name System (DNS)?

A Domain Name System (DNS) turns domain names into IP addresses, which allow browsers to get to websites and other internet resources.

What is Modem?

A modem (modulator-demodulator) is a device that modulates an analog signal to digital information. It also decodes carrier signals to demodulates the transmitted information

What are the Software Development Life Cycle?

Software Development Life Cycle or SDLC involves the following stages:

  • Requirement Analysis/ Planning
  • Defining
  • Design
  • Construction / Coding
  • Testing
  • Deployment
  • Maintenance

What do you mean by a Chipset?

A chipset helps you in controlling the communication between different devices and is crucial for determining whether a computer system is functioning properly or not. It controls the communication between all the computer components such as the CPU, the storage, and the RAM.

It tells you which and how many USB devices your motherboard can support. Primarily, chipsets help a computer system in controlling peripheral components such as the keyboard, monitor, mouse, or printer.

What does a chipset do?

A chipset is crucial for your computer system. It helps in controlling the communication between various components of your computer system. It can determine the functionality of your computer system. It monitors the peripheral components like keyboard, mouse, printer, etc.

What do you mean by Cryptography?

Cryptography, also known as cryptology, is the study and practice of techniques for secure communication. It focuses on studying techniques that prevent unwanted parties from accessing your information or communication.

What do you mean by an Algorithm?

An algorithm refers to a definite sequence of executable and well-defined instructions for solving a class of problems or performing a computation.

What is WWW (World Wide Web)?

The World Wide Web is an information system where web resources (such as documents) are accessible through the internet. Those resources can be interlinked by using hypertext and have Uniform Resource Locators (URLs) for identification.

What do you mean by the Internet?

The internet is a worldwide network of computers that allows you to access numerous communication and information facilities. In this system, the users at any computer system with the right permission, can get information from another computer system or interact with users of that system.

What is Software Requirement Specification (SRS)?

Software Requirement Specification (SRS) is a complete specification and description of requirements of the software that needs to be fulfilled for successful development of software system. These requirements can be functional as well as non-requirements depending upon the type of requirement.

What is Regression Testing?

Regression testing is defined as a type of software testing that is used to confirm that recent changes to the program or code have not adversely affected existing functionality.

What are the differences between SQL and NoSQL databases?

If you’re working with data, then you’ll need to have a strong grasp of both Structured Query Language (SQL) and Non-Structured Query Language (NoSQL.)

SQL is a query language that allows users to query and manipulate data within a relational database, which organizes data in columns and rows in a table. NoSQL, meanwhile, is a type of non-relational database that is capable of storing and managing large amounts of structured, semi-structured, and unstructured data.

What is software re-engineering?

It is a process of software development which is done to improve the maintainability of a software system.

What is Verification and Validation?

Verification:  Verification is a term that refers to the set of activities which ensure that software implements a specific function.

Validation:  It refers to the set of activities which ensure that software that has been built according to the need of clients.

What are functional and non-functional requirements?

Functional requirements are functional features which are expected by users from the proposed software product.

Non-functional requirements are related to security, performance, look, and feel of the user interface.

What is White Box, Black Box and Grey Box testing?

White Box Testing:

White Box Testing is a type of Software Testing in which the internal structure, design and implementation of the software application that is being tested is fully known to the tester.

Black Box Testing:

Black Box Testing is a software testing technique which is performed with no knowledge of a system’s internals, can be carried out to evaluate the functionality, security, performance, and other aspects of an application.

Gray Box Testing:

Gray Box Testing is a software testing technique which is a combination of Black Box Testing technique and White Box Testing technique. The internal structure, design and implementation is partially known in Gray Box Testing.

What are the phases of Computer Generations?

First Generation:

From:   1940s – 1950s

Based on:  Vacuum Tube Based

Second Generation:      

From:  1950s – 1960s

Based on: Transistor Based

Third Generation:          

From:  1960s – 1970s

Based on: Integrated Circuit

Fourth Generation:       

From:  1970s – Present

Based on: Microprocessor Based

Fifth Generation:           

From:  Present – Future

Based on:  Artificial Intelligence Based

What distinguishes RISC from CISC architecture?

RISC (Reduced Instruction Set Computing) architecture is designed around a small set of simple instructions, aiming for efficiency and speed. CISC (Complex Instruction Set Computing), on the other hand, includes a wide range of complex instructions, allowing for more versatile but potentially slower processing.

What is the Malware?

It is developed harmful software that invades or corrupts your computer network or Computer System. The goal of malware is to cause havoc and steal information or resources for monetary gain or sheer sabotage intent.

What are the Types of malware?

Viruses:

A virus is a type of malware that usually comes as an attachment in an email or through any other device or through the network of internet that holds some code that performs the malicious action. Once the victim opens the file, the device is infected. Virus need user interaction to spread itself.

Worms:

Worms have the ability to copy themselves from machine to machine, usually by exploiting some sort of security weakness in a software or operating system and don’t require user interaction to function. It does not need user interaction to spread itself.

Ransomware:

One of the most profitable, and therefore one of the most popular, types of malware amongst cybercriminals is ransomware. This malware installs itself onto a victim’s machine, encrypts their files, and then turns around and demands a ransom (usually in Bitcoin) to return that data to the user.

Spyware:

Spyware is a program installed on your computer, usually without your explicit knowledge, that captures and transmits personal information or Internet browsing habits and details to its user. Spyware enables its users to monitor all forms of communications on the targeted device. Spyware is often used by law enforcement, government agencies and information security organizations to test and monitor communications in a sensitive environment or in an investigation. But spyware is also available to consumers, allowing purchasers to spy on their spouse, children and employees.

Trojans:

Trojan viruses are disguised as helpful software programs. But once the user downloads it, the Trojan virus can gain access to sensitive data and then modify, block, or delete the data. This can be extremely harmful to the performance of the device. Unlike normal viruses and worms, Trojan viruses are not designed to self-replicate.

Adware:

Adware programs push unwanted advertisements at users and typically display blinking advertisements or pop-up windows when you perform a certain action. Adware programs are often installed in exchange for another service, such as the right to use a program without paying for it.

Leave a Reply

Your email address will not be published. Required fields are marked *