Friday, May 22, 2020

100+ Best Computer Science Interview Questions For Hiring - Algrim.co

100+ Best Computer Science Interview Questions For Hiring - Algrim.co 9. Compare method and constructor? Answer: Constructor: Used to initialize the instance of a class. Method: Used to perform some function or operation. Constructor: Doesn’t have a return type. Method: Has a return type. 10. What is a singleton class? Answer: Singleton class limits the number of objects created for a class to one but gives the flexibility of creating more objects if the situation changes. 11. What are the steps for creating the object? Answer: An object is first declared then instantiated and at last declared. For example Abc a= new Abc(); 12. What is the different type of access modifiers? Answer: There are four type of access modifiers as given below: • Visible to the overall package. No modifier needed. • Private â€" Visible to class only. • Public â€" Visible to the world. • Protected â€" Visible to package and subclass. 13. Which is the highest operator precedence in Java? Answer: The operator with the highest preference is Postfix operators i.e () []. 4. What is an array? Answer: The array is a container which holds the fixed number of similar data types. 15. What is the difference between equals() and method and == operator? Answer: The equals() is a method and it matches the content of the strings whereas == is an operator and matches object or reference of the strings. 16. Is string class final? Answer: Yes 17. What is a wrapper class? Answer: To access the primitive data type as an object we use wrapper class. They are following: Primitive Type Wrapper class boolean Boolean char Character byte Byte short Short int Integer long Long float Float double Double 18. Difference between overloading and overriding? Answer: Overloading is when two or more methods in the same class have the same method name but different parameters(i.e different method signatures). Overriding is when two methods having the same method name and parameters (i.e., method signature) but one of the methods is in the parent class and the other is in the child class. 19. What are multiple inheritances in Java? Answer: Java supports multiple inheritances i.e. the ability of a class to implement more than one interface. A class can implement multiple Interfaces but cannot extends multiple classes. 20. What is a stream? Answer: A stream can be defined as the sequence of data. There is two type of streams. InputStream: Used to read a data from a source. OutPut Stream: Used to write a data into a destination. 21. What is a Character stream? Answer: Java Character stream is basically used to perform input and output for 16 bit Unicode. The main classes users are FileReader and FileWriter which internally uses FileInputStream and FileOutputStream so the basic difference is that FileReader and FileWriter read and writes two bites at a time respectively. 22. What is a Byte stream? Answer: Java Byte stream is basically used to perform input and output for 8 bit Unicode. The main classes related to byte streams are FileInputStream and FileOutputStream. 23. What is an Interface? Answer: The interface is a reference type in Java, similar to the class but its collection of abstract methods. A class can implement multiple interfaces. 24. Difference between class and interface? Answer: Below are the difference between Interface and class: • The interface cannot be instantiated. • An interface doesn’t have any constructors. • Interface only have abstract methods. • A class implements an interface and extends a class. • An interface can extend multiple interfaces. 25. What is an abstract class? Answer: A class which contains the abstract keyword in a declaration is called abstract class. The properties of the abstract class are as follows: • Abstract classes may or may not contain abstract methods but, if a class has at least one abstract method, then it must be declared abstract. • The abstract class cannot be instantiated. • To use an abstract class, we have to inherit it from another class. • If we inherit an abstract class, then we have to provide implementations to all the abstract methods in it. 26. What is multiple inheritance? What are its advantages and disadvantages? Answer: Multiple inheritance is the process where a subclass can be derived from more than one super-class. Its advantage is that a class can inherit the functionality of more than one base class, but its disadvantage is that it can lead to a lot of confusion when two base classes implement a method with the same name. 27. Briefly describe the correct usage of the following HTML5 semantic elements Answer: • “The header element contains the introductory section of a page. It can also include the section heading, the author’s name, table of contents, or any other important navigational content.” • “The article element is used to house a piece of work that can be reused outside of the page without losing its intended meaning. News stories or blog posts are good examples of this.” • “The section tag is a versatile container meant for holding information that shares a common theme or purpose.” • “The footer element is designed to hold content that should appear at the bottom of a section or at the end of a page. This information might include the author’s name, related links, or copyright notices.” 28. What were some of the key goals and motivations for the HTML5 specification? Answer: HTML5 was designed to be able to replace HTML4, XHTML, and the HTML DOM Level 2. This new design provides better support for the web page structure through additional tags, ensures more consistent behavior across browsers, provides better cross-platform support, and delivers rich content like movies and graphics without the need for additional plug-ins. All of this not only makes design easier for the programmer, but it makes the end design more functional for the user. 29. What are some of the key new features in HTML5? Answer: Again, the interviewer will be looking to see not only if you’re aware of new versions of software, but also if you’re able to recognize the benefits and needs for them. By being familiar with the various features of HTML5, you’re showing that you stay current with industry trends and that you’re highly adaptable in the ever-changing tech scene. Some features you could mention include: • Improved support for embedding rich content like graphics, audio, and video • The introduction of web workers • New semantic tags including main, nav, article, section, header, footer, and aside • Extensions to the JavaScript API • Additional form controls like calendar, dates, time, email, url, and search 30. What are some advantages of using Python over other programming languages? Answer: Python has a wide variety of advantages over other programming languages, including: a. Its syntax is both easy to learn and easy to understand, reading more like a human language. b. It has large, standard libraries containing all areas like operating system interfaces, web service tools, and string operations. c. It also has extensive support libraries that drastically decrease time spent on coding, which in turn increases productivity, utilizing other languages like Java, C, C++, and C#. d. It has clean, object-oriented design and features strong integration processing capabilities. 31. Explain the difference between compile-time and runtime, then discuss how Python uses them during code checking. Answer: Both compile-time and runtime are programming terms that refer to various stages of software program development. Compile-time is the instance where the entered code is converted to executable, while runtime is the instance where the executable is running. Python performs some amount of compile-time code checking, although most of the checks don’t occur until code execution. 32. What is a view and what are some advantages of it? Answer: A view is a virtual table that contains rows and columns similar to a real table, yet does not contain data of its own. Some advantages of views are that they take up no space, they can be used to restrict access to the database, and they offer a simple way to retrieve complicated query results that need to be executed frequently. 33. Is it possible to find a loop in a Linked list? a. Possible at O(n) b. Not possible c. Possible at O(n^2) only d. Depends on the position of loop Answer: a. Possible at O(n) Have two pointers say P1 and P2 pointing to the first node of the list. Start a loop and Increment P1 once and P2 twice in each iteration. At any point of time if P1==P2 then there is a loop in that linked list. If P2 reaches NULL (end of linked list) then no loop exists. 34. Two linked lists L1 and L2 intersects at a particular node N1 and from there all other nodes till the end are common. The length of the lists are not same. What are the possibilities to find N1? a. Solution exist for certain cases only b. No linear solution exist c. Linear solution is possible d Only Non-linear solution exist. Answer: c. Linear solution is possible Have two pointers say P1 pointing to the first node of L1 and P2 to that of L2. Traverse through both the lists. If P1 reaches L1’s last node, point it to the first node of L2 and continue traversing. Do the same thing for P2 when it reaches L2’s last node. (By doing this, we are balancing the difference in the length between the linked lists. The shorter one will get over soon and by redirecting to longer list’s head, it will traverse the extra nodes also.) Finally, they will meet at the Intersection node. 35. Given a Binary Search Tree (BST), print its values in ascending order. a. Perform Depth first traversal b. Perform Breadth first traversal c. Perform Postorder traversal d. Perform Inorder traversal Answer: d. Perform Inorder traversal. It is the properfy of BST and Inorder traversal. 36. Is it possible to implement a queue using Linked List ? Enqueue & Dequeue should be O(1). a. Not possible to implement. b Only Enqueue is possible at O(1). c. Only Dequeue is possible at O(1). d. Both Enqueue and Dequeue is possible at O(1) Answer: d. Both Enqueue and Dequeue is possible at O(1) Have two pointers H pointing to the Head and T pointing to the Tail of the linked list. Perform enqueue at T and perform dequeue at H. Update the pointers after each operation accordingly. 37. Given a Tree, is it possible to find the greatest and least among leaves in linear time? a. Solution depends on the tree structure b. Linear solution exist c. Only Non-linear solution exist d. No linear solution exists Answer: b. Linear solution exist Have two variables Min and Max. Perform any tree traversal. Assign the first traversed leaf element to Min and Max for all other leaf elements check with these variables and update it accordingly. If a current element is Min then check with Max. Note: If you want to find the greatest and least among all nodes perform the checks for each node traversed. 38. Is it possible to find the greatest and least value among the nodes in a given BST without using any extra variables? a. No solution exists. b. Solution need 2 extra variables c. Solution exist without any extra variables d Solution need 1 extra variable Answer: c. Solution exist without any extra variables As per BST property, the left most node should be the least one and the rightmost node should be the greatest. In other words, the first and last node of an Inorder traversal are the least and greatest among the nodes respectively. 39. Is it possible to implement 2 stack in an array? Condition: None of the stack should indicate an overflow until every slot of an array is used. a. Only 1 stack can be implemented for the given condition b. Stacks cannot be implemented in array c. 2 stacks can be implemented for the given condition d. 2 stacks can be implemented if the given condition is applied only for 1 stack Answer: c. 2 stacks can be implemented for the given condition Start 1st stack from left (1st position of an array) and 2nd from right (last position say n).Move 1st stack towards right (i.e. 1, 2, 3 ...n) and 2nd towards left (i.e. n, n-1, n-2...1). 40. Given two keys K1 & K2, write an algorithm to print all the elements between them with K1 a. Solution need 2 extra spaces b. Linear solution is possible without using any extra space c. No linear solution exist d. Solution need 1 extra space Answer: b. Linear solution is possible without using any extra space Perform an inorder traversal. Once you find K1 print it and continue traversal now, print all other traversed elements until you reach K2. Note: If K1 == K2 stop once you find K1. 41. How many numbers of addresses are usable for addressing in a Class C network? Answer: c. 254 The number of addresses usable for addressing specific hosts in each network is always 2 power N - 2 (where N is the number of rest field bits, and the subtraction of 2 adjusts for the use of the all-bits-zero host portion for network address and the all-bits-one host portion as a broadcast address. Thus, for a Class C address with 8 bits available in the host field, the number of hosts is 254 • Class A 0.0.0.0 - 127.255.255.255 • Class B 128.0.0.0 - 191.255.255.255 • Class C 192.0.0.0 - 223.255.255.255 • Class D 224.0.0.0 - 239.255.255.255 • Class E 240.0.0.0 - 247.255.255.255 42. How are the data units at Application layer is called? Answer: The data unit created at the application layer is called a message, at the transport layer the data unit created is called either a segment or a user datagram, at the network layer the data unit created, is called the datagram, at the data link layer the datagram is encapsulated in to a frame and finally transmitted as signals along the transmission media. 43. What protocol is used by DNS name servers? Justify. Answer: DNS uses UDP for communication between servers. It is a better choice than TCP because of the improved speed a connectionless protocol offers. Of course, transmission reliability suffers with UDP 44. Which of the following is used to direct a packet inside an internal network? a. Routers b. Modem c. Gateway d. None of the above Answer: a. Routers Routers are machines that direct a packet through the maze of networks that stand between its source and destination. Normally a router is used for internal networks while a gateway acts a door for the packet to reach the ‘outside’ of the internal network. 45. What’s the Software Testing? Answer: A set of activities conducted with the intent of finding errors in software. 46. What is Acceptance Testing? Answer: Testing conducted to enable a user/customer to determine whether to accept a software product. Normally performed to validate the software meets a set of agreed acceptance criteria. 47. What is Accessibility Testing? Answer: Verifying a product is accessible to the people having disabilities (deaf, blind, mentally disabled etc.). 48. What is Ad Hoc Testing? Answer: A testing phase where the tester tries to 'break' the system by randomly trying the system's functionality. 49. What is Application Programming Interface (API)? Answer: A formalized set of software calls and routines that can be referenced by an application program in order to access supporting system or network services. 50. What is Backus-Naur Form? Answer: A metalanguage used to formally describe the syntax of a language. 51. What is Beta Testing? Answer: Testing of a release of a software product conducted by customers. 52. What is Application Binary Interface (ABI)? Answer: A specification defining requirements for portability of applications in binary forms across different system platforms and environments. 53. What is Binary Portability Testing? Answer: Testing an executable application for portability across system platforms and environments, usually for conformity to an ABI specification. 54. What is the difference between verification and validation? Answer: Verification is a review without actually executing the process while validation is checking the product with actual execution. For instance, code review and syntax check is verification while actually running the product and checking the results is validation. 55. What is Bug? Answer: A fault in a program which causes the program to perform in an unintended or unanticipated manner. 56. What is Defect? Answer: If software misses some feature or function from what is there in requirement it is called a defect. 57. What is Branch Testing? Answer: Testing in which all branches in the program source code are tested at least once. 58. What is Breadth Testing? Answer: A test suite that exercises the full functionality of a product but does not test features in detail. 59. What's the Alpha Testing? Answer: The Alpha Testing is conducted at the developer sites and in a controlled environment by the end user of the software 60. What's the Beta Testing? Answer: Testing the application after the installation at the client place. 61. What is Component Testing? Answer: Testing of individual software components (Unit Testing). 62. What is End-to-End testing? Answer: Testing a complete application environment in a situation that mimics real-world use, such as interacting with a database, using network communications, or interacting with other hardware, applications, or systems if appropriate. 63. What is CAST? Answer: Computer Aided Software Testing. 64. What is CMM? Answer: The Capability Maturity Model for Software (CMM or SW-CMM) is a model for judging the maturity of the software processes of an organization and for identifying the key practices that are required to increase the maturity of these processes. 65. What is Compatibility Testing? Answer: Testing whether software is compatible with other elements of a system with which it should operate, e.g. browsers, Operating Systems, or hardware. 66. What is Debugging? Answer: The process of finding and removing the causes of software failures. 67. What is Dependency Testing? Answer: Examines an application's requirements for pre-existing software, initial states and configuration in order to maintain proper functionality. 68. What’s the Database testing? Answer: In database testing, we can check the integrity of database field values. 69. What is the difference between interoperability and compatibility testing with some examples? Answer: Interoperability: To check if the software can co-exist with other supporting software in the system Compatibility: To check if the software runs on different types of operating systems according to customer requirements. 70. What’s the Test Case? Answer: A set of test inputs, execution, and expected result developed for a particular objective. 71. What’s the Traceability Matrix? Answer: A document that showing the relationship between Test Requirements and Test Cases. 72. How many types of approaches are used in Integration Testing? Answer: There are two types of approaches used: Bottom-Up Top-Down 73. What is Emulator? Answer: A device, computer program, or system that accepts the same inputs and produces the same outputs as a given system. 74. What is Functional Decomposition? Answer: A technique used during planning, analysis, and design; creates a functional hierarchy for the software. 75. What is Integration Testing? Answer: Testing of combined parts of an application to determine if they function together correctly. Usually performed after unit and functional testing. This type of testing is especially relevant to client/server and distributed systems. 76. What is Metric? Answer: A standard of measurement. Software metrics are the statistics describing the structure or content of a program. A metric should be a real objective measurement of something such as a number of bugs per lines of code. 77. What is Quality Assurance? Answer: All those planned or systematic actions necessary to provide adequate confidence that a product or service is of the type and quality needed and expected by the customer. 78. What is Race Condition? Answer: A cause of concurrency problems. Multiple accesses to a shared resource, at least one of which is a write, with no mechanism used by either to moderate simultaneous access. 79. What is Scalability Testing? Answer: Performance testing focused on ensuring the application under test gracefully handles increases in workload. 80. What is Software Requirements Specification? Answer: A deliverable that describes all data, functional and behavioral requirements, all constraints, and all validation requirements for software. 81. What is an operating system? Answer: An operating system is a program that acts as an intermediary between the user and the computer hardware. The purpose of an OS is to provide a convenient environment in which a user can execute programs in a convenient and efficient manner. 82. What are the different operating systems? Answer: 1. Batched operating systems 2. Multi-programmed operating systems 3. timesharing operating systems 4. Distributed operating systems 5. Real-time operating systems 83. What are the basic functions of an operating system? Answer: Operating system controls and coordinates the use of the hardware among the various applications programs for various uses. Operating system acts as resource allocator and manager. Also operating system is control program which controls the user programs to prevent errors and improper use of the computer. It is especially concerned with the operation and control of I/O devices. 84. What is a kernel? Answer: The kernel is the core and essential part of a computer operating system that provides basic services for all parts of OS. 85. What is the difference between microkernel and macro kernel? Answer: The microkernel is a kernel which run services those are minimal for operating system performance. In this kernel, all other operations are performed by the processor. Macro Kernel is a combination of micro and monolithic kernel. In monolithic kernel, all operating system code is in the single executable image. 86. What is deadlock? Answer: Deadlock is a situation or condition where the two processes are waiting for each other to complete so that they can start. This result both the processes to hang. 87. What is a computer process? Answer: A program in execution is called a process. Processes are of two types: 1. Operating system processes 2. User processes 88. What are the states of a process? Answer: 1. New 2. Running 3. Waiting 4. Ready 5. Terminated 89. What are starvation and aging? Answer: Starvation is 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 is a technique to avoid starvation in a scheduling system. 90. What is semaphore? Answer: Semaphore is a variable, whose status reports common resource, Semaphore is of two types one is Binary semaphore and other is Counting semaphore. 91. What is context switching? Answer: Transferring control from one process to other process requires saving the state of the old process and loading the saved state for a new process. This task is known as context switching. 92. What is a thread? Answer: A thread is a program line under execution. Thread sometimes called a light-weight process, is a basic unit of CPU utilization; it comprises a thread id, a program counter, a register set, and a stack. 93. What is process synchronization? Answer: A situation, where several processes access and manipulate the same data concurrently and the outcome of the execution depends on the particular order in which the access takes place, is called a race condition. To guard against the race condition we need to ensure that only one process at a time can be manipulating the same data. The technique we use for this is called process synchronization. 94. What is virtual memory? Answer: Virtual memory is a hardware technique where the system appears to have more memory than it actually does. This is done by time-sharing, the physical memory and storage parts of the memory one disk when they are not actively being used. 95. What is thrashing? Answer: It is a phenomenon in virtual memory schemes when the processor spends most of its time swapping pages, rather than executing instructions. This is due to an inordinate number of page faults. 96. What is fragmentation? Tell about different types of fragmentation? Answer: When many of free blocks are too small to satisfy any request then fragmentation occurs. External fragmentation and internal fragmentation are two types of fragmentation. External Fragmentation happens when a dynamic memory allocation algorithm allocates some memory and a small piece is left over that cannot be effectively used. Internal fragmentation is the space wasted inside of allocated memory blocks because of restriction on the allowed sizes of allocated blocks. 97. What is cache memory? Answer: Cache memory is random access memory (RAM) that a computer microprocessor can access more quickly than it can access regular RAM. As the microprocessor processes data, it looks first in the cache memory and if it finds the data there (from a previous reading of data), it does not have to do the more time-consuming reading of data from larger memory. 98. What is Throughput, Turnaround time, Waiting time and Response time? Answer: Throughput â€" number of processes that complete their execution per time unit Turnaround time â€" amount of time to execute a particular process Waiting time â€" amount of time a process has been waiting in the ready queue Response time â€" amount of time it takes from when a request was submitted until the first response is produced, not output (for time-sharing environment) 99. What are the sub-components of I/O manager in Windows NT? Answer: • Network redirector/ Server • Cache manager • File systems • Network driver • Device driver 100. What is a dual-mode operation? Answer: In order to protect the operating systems and the system programs from the malfunctioning programs the two-mode operations were evolved: System mode, User mode. 101. What is a relative path and absolute path? Answer: Absolute path-- The exact path from a root directory Relative path-- Relative to the current path 102. What are the disadvantages of context switching? Answer: Time taken for switching from one process to other is pure overhead. Because the system does no useful work while switching. So one of the solutions is to go for threading whenever possible. 103. What is a data register and address register? Answer: Data registers - can be assigned to a variety of functions by the programmer. They can be used with any machine instruction that performs operations on data. Address registers - contain main memory addresses of data and instructions or they contain a portion of the address that is used in the calculation of the complete addresses. 104. What is DRAM? Answer: Dynamic Ram stores the data in the form of Capacitance, and Static RAM stores the data in Voltages. 105. What are local and global page replacements? Answer: Local replacement means that an incoming page is brought in only to the relevant process' address space. Global replacement policy allows any page frame from any process to be replaced. The latter is applicable to variable partitions model only. 106. Explain the concept of batched operating systems? Answer: In a batched operating system the users give their jobs to the operator who sorts the programs according to their requirements and executes them. This is time-consuming but makes the CPU busy all the time. 107. What is SCSI? Answer: SCSI - Small computer systems interface is a type of interface used for computer components such as hard drives, optical drives, scanners, and tape drives. It is a competing technology to standard IDE (Integrated Drive Electronics). These were some of the probable questions for anyone who aims for a job in the CS sector.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.