Practice IT Operating System Questions and Answers
- Complete the C function to calculate the length of a null-terminated string s without using strlen. int custom_strlen(const char* s) { Β Β int length = 0...
- Complete the Python function to return the last n characters of a string s. If n is greater than the string's length, return the entire string. def get_las...
- Inheritance is an OOP principle that establishes an "is-a" relationship between classes. What does this relationship primarily allow?
- Consider the following Python code: class Vehicle: Β Β def __init__(self, brand): Β Β Β Β self.brand = brand Β Β def display_info(self): Β Β Β οΏ½...
- The following Java code attempts to demonstrate multiple inheritance, which is not directly supported for classes in Java. How can similar functionality be...
- Which type of inheritance in C++ allows a class to inherit from more than one base class?
- In Python, if a method in a subclass has the same name as a method in its superclass, which method will be called when invoked on an object of the subclass...
- Consider the following Java code: class Animal { Β Β String type = "Generic Animal"; Β Β void eat() { Β Β Β Β System.out.println("Animal eats food....
- The following C++ code has a common inheritance-related issue. How can it be debugged to ensure the derived class constructor properly initializes the base...
- The following Python code attempts to call a method from the parent class, but it's using an outdated or incorrect syntax. How should it be corrected? clas...
- What is the keyword used in Java to indicate that a class is inheriting from another class?
- Consider the following C++ code: #include class Base { public: Β Β Base() { Β Β Β Β std::cout ...
- Consider the following Python code: list_a = [1, 2, 3] tuple_b = (4, 5) string_c = "hello" dict_d = {"key1": 1, "key2": 2} print(len(list_a) + len(tuple_b)...
- Consider the following Java code: public class SubstringDryRun { Β Β public static void main(String[] args) { Β Β Β Β String s = "Programming"; Β Β ...
- Consider the following Python code: import re text = "apple, banana, cherry. apple pie, banana split." pattern = r"\bapple\b|\bbanana\b" matches = re.finda...
- Consider the following C code: #include #include int main() { Β Β char* text = "The quick brown fox jumps over the lazy dog."; Β Β char* pattern = "f...
- Consider the following Java code: public class LengthMix { Β Β public static void main(String[] args) { Β Β Β Β int[] numbers = {10, 20, 30, 40}; Β ...
- Consider the following Python code: s = "PythonProgramming" part1 = s[2:6] # Corrected line part2 = s[-5:] print(part1 + part2) What will be the output of ...
- Consider the following Java code: import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexGroup { Β Β public static void main(S...
- Consider the following Python code: text = "banana" char_to_find = 'a' count = 0 for i in range(len(text)): Β Β if text[i] == char_to_find: Β Β Β Β c...
- Consider the following C code: #include #include int main() { Β Β char str1[] = "Hello"; Β Β char str2[] = {'W', 'o', 'r', 'l', 'd', '\0', 'X'}; Β οΏ½...
- Consider the following Java code: import java.util.Arrays; public class Splitter { Β Β public static void main(String[] args) { Β Β Β Β String data =...
- In a Selection Sort algorithm, the inner loop finds the index of the minimum element in the unsorted part. Which line correctly completes the if condition ...
- Complete the while loop condition for an iterative binary search implementation. def binary_search(arr, target): Β Β low = 0 Β Β high = len(arr) - 1 Β ...
- In a Ternary Search algorithm, the array is divided into three parts. Complete the calculation for mid1 and mid2. def ternary_search(arr, target): Β Β lo...
- When building a Huffman tree, the two nodes with the smallest frequencies are combined. Which line correctly creates a new parent node newNode with left an...
- The first step in the greedy Activity Selection problem is to sort the activities. Which criterion is used for sorting to ensure the greedy choice property...
- In the dynamic programming solution for Matrix Chain Multiplication, the outermost loop iterates over the len (chain length). What are the correct loop bou...
- Complete the recurrence relation for dp[i][j] in the Longest Common Subsequence (LCS) problem when text1[i-1] is *not equal* to text2[j-1]. # dp[i][j] stor...
- In a common backtracking approach to generate permutations of a string, elements are swapped to explore different arrangements. Complete the line that swap...
- In a recursive subset_sum function, backtrack(index, current_subset, current_sum), to explore the option of *including* the current element arr[index], whi...
- In the Knuth-Morris-Pratt (KMP) algorithm, the Longest Proper Prefix Suffix (LPS) array lps[] is crucial. When pat[i] and pat[len] match, len is incremente...
- A Python function get_element(arr, index) is supposed to return the element at a given index. def get_element(arr, index): Β Β # Assume arr is a list of ...
- Consider a Java method printList(Node head) for a singly linked list. class Node { Β Β int data; Β Β Node next; Β Β Node(int d) { data = d; next = nu...
- A C function pop(Stack* s) is designed to remove and return the top element from a stack. #include #include #define MAX_SIZE 10 typedef struct { Β Β in...
- A Python Queue class uses a list. Its is_empty method is implemented incorrectly. class Queue: Β Β def __init__(self): Β Β Β Β self._items = [] Β Β ...
- A Java method isLeaf(TreeNode node) is intended to check if a given node is a leaf in a binary tree. class TreeNode { Β Β int val; Β Β TreeNode left, r...
- A C function insert(Node* root, int data) for a BST. #include typedef struct Node { Β Β int data; Β Β struct Node *left, *right; } Node; Node* newNode...
- Java MinHeap class has a heapifyDown method. public class MinHeap { Β Β private ArrayList heap; Β Β public MinHeap() { Β Β Β Β heap = new ArrayList...
- You are using Python's built-in dict to store custom objects. class MyObject: Β Β def __init__(self, value): Β Β Β Β self.value = value Β Β # Missi...
More Topics
- Algorithms Questions
- Analog and Digital Communication Questions
- Artificial Intelligence & Machine Language Questions
- Basics of Computers Questions
- Big Data Analytics Questions
- C Programming Questions
- C++ Questions
- Cloud Computing Questions
- Compiler Design Questions
- Computer Architecture and Design Questions
- Cyber Security Questions
- Data Analytics Languages Questions
- Data Structure Questions
- Data Warehousing Questions
- Digital Logic Questions
- Emerging Technologies Questions
- IOT and mobile Computing Questions
- IT DBMS Questions
- IT Networking Questions
- Java Language Questions
- Machine Learning Questions
- Memory Management Questions
- Microsoft Office Questions
- Miscellaneous Questions Questions
- Network Layer and IP Protocol Questions
- Numerical and Statistical Computing Questions
- Object Oriented Programming Questions
- OOPS Concepts Questions
- Previous Year Questions Questions
- Programming Concept Questions
- Python Questions
- Shell Scripting Questions
- Software Engineering and Web Technology Questions
- SQL Questions
- String Manipulation Questions
- TCP IP and OSI Questions