Join Regular Classroom : Visit ClassroomTech

Itron Overall Interview Questions + Coding Solutions codewindow.in

Hot Topics

Itron Solution

Technical Round

Difference between interface and abstract

Interface
Abstract class
1. Interface supports the concept of multiple inheritance.
Abstract class doesn’t support the concept of multiple inheritance.
2. Interface has only abstract methods.
Abstract class can have non-abstract method but it must have at least one abstract method.
3. Interface keyword is used to declare interface
Abstract keyword is used to declare Abstract class.
4. Interface has members as public by default.
Abstract class in Java can have private, protected, public and default class members.
5. Interface supports multiple inheritance.
Abstract class does not support multiple inheritance.
 

Who was the first person to develop Java and when?

James Gosling developed Java in 1995

Do you know any scripting language?

Tell yes if you know scripting languages like JavaScript, Typescript, etc. or else tell no.

Difference between C and C++.

C
C++
1. C was developed by Dennis Ritchie in 1972.
C++ was developed by Bjame Stroustrup in 1979.
2. C is a Procedural Programming language.
C++ is an Object Oriented programming language.
3. C is a subset of C++.
C++ is a superset of C.
4. C contains 32 keywords.
C++ contains 52 keywords.
5. C does not support inheritance, polymorphism, encapsulation and abstraction.
C++ supports inheritance, polymorphism, encapsulation and abstraction.
6. Function and operator overloading is not supported in C.
Function and operator overloading is supported in C++.

Write a C program to insert an element in an array.

#include <stdio.h>

int main() {
    int i, n, pos, ele, arr[100];
    printf("Enter the number of elements in the array: ");
    scanf("%d", &n);

    printf("Enter the elements of the array: ");
    for (i = 0; i < n; i++) {
        scanf("%d", &arr[i]);
    }
    printf("Enter the element to be inserted: ");
    scanf("%d", &ele);
    printf("Enter the position where the element should be inserted: ");
    scanf("%d", &pos);
    for (i = n; i >= pos; i--) {
        arr[i] = arr[i - 1];
    }
    arr[pos - 1] = ele;
    printf("The updated array is: ");
    for (i = 0; i <= n; i++) {
        printf("%d ", arr[i]);
    }

    return 0;
}
/*
OUTPUT
Enter the number of elements in the array: 5
Enter the elements of the array: 1
2
3
4
6
Enter the element to be inserted: 8
Enter the position where the element should be inserted: 2
The updated array is: 1 8 2 3 4 6 */

How to check Palindrome String in Python?

A string is called a palindrome if it reads the same forwards and backwards. Here’s one way to check if a string is a palindrome in Python:
def is_palindrome(s):
    return s == s[::-1]

# test
s = "racecar"
print(is_palindrome(s)) # True

#OUTPUT - True
In the is_palindrome function, the string is sliced using [::-1], which returns a reversed version of the string. The function returns True if the reversed string is equal to the original string, and False otherwise.

How to implement a factory pattern without using any if-else if construct or switch-case construct?

One way to implement the factory pattern in Python without using if-else if or switch-case is to use a dictionary to map types to their corresponding class or function.
Here’s an example of how you could use a dictionary to implement a simple shape factory:
class Shape:
    def __init__(self, type):
        self._type = type

    def draw(self):
        pass

class Rectangle(Shape):
    def draw(self):
        print("Inside Rectangle::draw() method.")

class Square(Shape):
    def draw(self):
        print("Inside Square::draw() method.")

class Circle(Shape):
    def draw(self):
        print("Inside Circle::draw() method.")

class ShapeFactory:
    def __init__(self):
        self._creators = {}

    def register_creator(self, type, creator):
        self._creators[type] = creator

    def create_shape(self, type):
        if type not in self._creators:
            raise ValueError("Invalid shape type")
        return self._creators[type]()

factory = ShapeFactory()
factory.register_creator("circle", Circle)
factory.register_creator("rectangle", Rectangle)
factory.register_creator("square", Square)

shape = factory.create_shape("circle")
shape.draw()
In the above example, we register the different shape classes with the factory using the register_creator method. When we want to create an instance of a specific shape, we call the create_shape method and pass in the type of shape we want. The factory then looks up the corresponding class in the dictionary and returns an instance of that class. This way the factory is not dependent on any if-else if or switch-case construct.

Use of static in C++. Is the class containing static members inheritable? Can u use the static keyword in your project? How?

In C++, the static keyword is used in several contexts:
  1. Static local variables: A static local variable retains its value between function calls.
  2. Static class members: A static class member is shared by all objects of the class, and it is accessible even when no objects of the class exist.
  3. Static functions: A static member function can access only static data members, other static member functions, and any data and functions that are not associated with the class or its objects.
A class containing static members is inheritable, but the static members themselves are not inherited by the derived class.
Yes, you can use the static keyword in your project by declaring static data members, static member functions, and static local variables, depending on the specific requirements of your project. For example:
class MyClass
{
  static int s_count;
  
public:
  MyClass()
  {
    ++s_count;
  }
  
  static int getCount()
  {
    return s_count;
  }
};

int MyClass::s_count = 0;

int main()
{
  MyClass a, b, c;
  cout << MyClass::getCount() << endl; 
  return 0;
}
/*
OUTPUT - 
3
*/
In this example, the class MyClass has a static integer member s_count, which is shared by all objects of the class and is incremented each time an object is created. The getCount function returns the current value of s_count.

Given arrays A, and B, find the elements in A which are not in B.

To find the elements in array A that are not in array B, you can use a combination of loops and conditional statements. One approach is to use a nested loop to compare each element in A with each element in B, and if a match is not found, the element is added to a new list or outputted directly. Here’s an example in Python:
def find_unique(A, B):
    result = []
    for a in A:
        found = False
        for b in B:
            if a == b:
                found = True
                break
        if not found:
            result.append(a)
    return result

# test
A = [1, 2, 3, 4, 5]
B = [3, 4, 5, 6, 7]
print(find_unique(A, B)) 

# OUTPUT - [1,2]
In this example, the function find_unique takes two arrays A and B as inputs and returns a list of elements in A that are not in B. The function uses a nested loop to compare each element in A with each element in B, and if a match is not found, the element is added to the result list.

What is priority queue? Given a sequence of integers with different priorities, how will they be arranged in the priority queue?

A priority queue is a data structure that stores elements with associated priority values. Elements with higher priority values are considered more “important” and are given priority over elements with lower priority values.
In a priority queue, elements are usually arranged such that the element with the highest priority is at the front of the queue and the element with the lowest priority is at the back.
When inserting a new element into the priority queue, the element’s priority is compared to the priorities of the other elements already in the queue. The element is then inserted into the correct position in the queue based on its priority value.
When removing an element from the priority queue, the element with the highest priority is usually the first one to be removed.
In Python, the heapq module provides an implementation of a priority queue using a heap data structure. You can use the heapq.heappush() function to add elements to the priority queue, and the heapq.heappop() function to remove the element with the highest priority.
Here’s an example of how you could use a priority queue to store a sequence of integers with different priorities:
import heapq

# Create a priority queue
priority_queue = []

# Add elements to the priority queue with different priorities
heapq.heappush(priority_queue, (3, 'low_priority_task'))
heapq.heappush(priority_queue, (1, 'high_priority_task'))
heapq.heappush(priority_queue, (2, 'normal_priority_task'))

# Remove elements from the priority queue
print(heapq.heappop(priority_queue)) # will print (1, 'high_priority_task')
print(heapq.heappop(priority_queue)) # will print (2, 'normal_priority_task')
print(heapq.heappop(priority_queue)) # will print (3, 'low_priority_task')

# OUTPUT
#        (1, 'high_priority_task')
#        (2, 'normal_priority_task')
#        (3, 'low_priority_task')
Here the priority queue is implemented using the heapq module, we push the elements in the priority queue, giving them a priority value, in this case, the integers are the priority value of the elements, and the string is the element. And when we pop the elements from the priority queue, it returns the elements according to their priority value.

Questions related to Indexing in DBMS.

Indexing in a database management system (DBMS) is the process of creating a data structure that allows for faster retrieval of data from a table or view. It is used to improve the performance of queries by reducing the amount of data that needs to be scanned.
There are several types of indexes that can be used in a DBMS, including:
  • B-Tree index: This is a type of index that uses a balanced tree data structure. It is commonly used in relational databases and allows for fast search, insertion, and deletion operations.
  • Hash index: This type of index uses a hash function to map data to specific locations in the index. It is typically used for exact-match lookup operations, such as primary key lookups.
  • Bitmap index: This type of index uses a bitmap to represent the presence or absence of a value in a table. It is generally used for data warehousing and business intelligence applications where queries involve multiple conditions.
  • Clustered index: This type of index determines the physical order of data in a table. A table can have only one clustered index, and it is usually created on the primary key of the table.
  • Non-Clustered index: This type of index does not determine the physical order of data in a table. A table can have multiple non-clustered indexes.
It’s worth noting that over-indexing can also cause performance issues, as indexes also take up storage space and can slow down data modification operations, so it’s important to find a balance between good query performance and efficient data modification operations when creating indexes.
Indexing is a crucial aspect of DBMS performance, it’s important to understand the different types of indexes available and the trade-offs of each, as well as the specific needs of your application when choosing which indexes to create.

Describe some of the principles of object-oriented programming.

The 4 principles of OOPs are:
  • Inheritance: It is a concept of Object Oriented Programming in which a new class is created from the existing one.
  • Polymorphism: Poly means many and morph means form. A concept that enables programmers to assign a different meaning or usage to a variable, function or an object in different context.
 
Polymorphism can be of two types:
  1. Runtime Polymorphism
  2. Compile Time Polymorphism
  • Abstraction: Creating a new data type using encapsulated items that is well suited for an application.
  • Encapsulation: It is called data hiding and encapsulation is the way of packing data and function into a single unit to hide the implementation details of a class from outer world.

Nagarro Solved

Automata Fixing

      

We Love to Support you

Go through our study material. Your Job is awaiting.

Recent Posts
Categories