Join Regular Classroom : Visit ClassroomTech

Incture Interview Questions +Coding Solutions – codwindow.in

Hot Topics

Incture Solution

Technical Round

What is the base class of Exceptions and error?

In Python, the base class for exceptions and errors is the Exception class. It is defined in the builtins module and is the root of the exception hierarchy in Python. All exceptions and errors in Python are derived from this base class, either directly or indirectly.
For example, common exceptions in Python such as ValueError, TypeError, and KeyError are all derived from the Exception class.
Here’s an example of how the Exception class is used:
try:
    # some code that might raise an exception
except Exception as e:
    # handle the exception
In this example, if an exception is raised in the try block, it will be caught and stored in the variable e. You can then handle the exception by printing an error message or performing some other action. If the exception is not caught in this way, it will be propagated up the call stack until it is caught or until the program terminates.

Java JDBC and remote APIs

Java JDBC (Java Database Connectivity) is a Java API that allows Java programs to interact with relational databases. It provides a set of classes and interfaces for establishing connections to a database, executing SQL statements, and retrieving results.
Remote APIs refer to the APIs that allow applications to communicate and interact with remote services over a network, such as APIs that access cloud services, web services, or other external systems.
In the context of Java JDBC, a remote API can be used to access a database that is located on a different server or in the cloud. For example, you can use a remote API to connect to a database running on a remote server, execute SQL statements on the remote database, and retrieve results from the remote database. This enables you to create applications that can interact with remote databases and perform tasks such as storing and retrieving data, querying data, and updating data.
There are many different remote APIs available for Java JDBC, including APIs for different databases (such as MySQL, Oracle, and Microsoft SQL Server), different cloud platforms (such as Amazon Web Services and Microsoft Azure), and different web services (such as RESTful APIs and SOAP APIs). To use a remote API, you will typically need to configure a connection to the remote database or service, and you may need to provide credentials or other information to access the remote system.

3 bulbs puzzle, Elevator Puzzle.

The 3 bulbs puzzle is a classic logical puzzle that involves three light bulbs and three switches. The puzzle goes as follows:
  1. You are in a room with three light bulbs and three switches, but you do not know which switch controls which bulb.
  2. You can turn the switches on and off as many times as you want, but you cannot see the bulbs (they are behind a wall).
  3. The goal is to figure out which switch controls which bulb.
The solution to this puzzle is to turn on the first switch, wait for a few minutes, and then turn it off. Repeat this process with the second switch, and then the third switch. After you have turned off the third switch, go into the room and see which bulb is still on. The switch that controls the bulb that is still on is the first switch, the bulb that is off but warm is the second switch, and the bulb that is off and cold is the third switch.
The Elevator Puzzle is a classic puzzle that involves an elevator, several people, and several floors. The puzzle goes as follows:
  1. There is an elevator in a building with several floors.
  2. There are several people in the building, and each person wants to go to a different floor.
  3. The elevator can only hold a limited number of people, and it can only travel between floors.
  4. The goal is to figure out the most efficient way to get all the people to their desired floors while minimizing the number of trips the elevator has to make.
The solution to this puzzle involves figuring out the most efficient way to arrange the people in the elevator and determine the order in which they should be taken to their desired floors. To minimize the number of trips the elevator has to make, you should arrange the people so that they are going to the floors that are closest together, and you should take the people to the floors in a logical order that minimizes the amount of time the elevator has to spend traveling between floors.

What is Interface in Java?

In Java, an interface is a blueprint for objects that specifies a set of methods that must be implemented by any class that implements the interface. An interface defines a contract that any class that implements it must fulfill.
An interface does not provide an implementation for the methods it defines. Instead, it defines the method signatures, which include the method name, return type, and parameters. Classes that implement the interface must provide an implementation for the methods defined in the interface.

What are the access modifier and their use?

In Java, access modifiers are special keywords which are used to restrict the access of a class, constructor, data member and method in another class. Java supports four types of access modifiers:
  • Default: declarations are visible only within the package.
  • Private: declarations are only visible within the class.
  • Protected: declarations are visible within the package or all subclasses.
  • Public: declarations are visible everywhere.
Modifier
Default
Private
Protected
Public
Same Class
YES
YES
YES
YES
Same package subclass
YES
NO
YES
YES
Same package non-subclass
YES
NO
YES
YES
Different package subclass
NO
NO
YES
YES
Different package non-subclass
NO
NO
NO
YES
 

Difference between JSP and Servlet?

 
JSP
Servlet
1.     JSP is a HTML based code
Servlet is a Java based code
2.     In JSP it is easy to write code as it is Java in HTML.
In Servlet it is difficult to write code as it is HTML in Java.
3.     JSP acts like a view in MVC architecture.
Servlet acts like a controller in MVC architecture.
4.     JSP can only accept HTTP requests.
Servlet can accept all kind of protocol requests.
5.     service() cannot be overridden as it is a HTML based code.
service() can be overridden as it is Java based code.
 

How do we write the java code inside JSP?

In JSP (JavaServer Pages), you can write Java code directly inside the JSP page using scriptlets. A scriptlet is a block of Java code that is enclosed within the tags <% and %>.
Here is an example of how you would use a scriptlet to display the current date in a JSP page:
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Current Date</title>
</head>
<body>
  <h1>Current Date</h1>
  <%
    java.util.Date date = new java.util.Date();
  %>
  <p>The current date is: <%= date %></p>
</body>
</html>

Difference between Join and Union.

JOIN
UNION
1.     JOIN combines two different tables when they have a common attribute. 
UNION combines the result based on two or more query.
2.     Number of columns selected after performing JOIN operation may not be same.
Number of columns selected is same. 
3.     It may not return distinct columns.
It returns distinct rows.
 

What is Cloud?

Cloud is a technology that provides everyone the facility of accessing data and cloud applications with the help of internet from remote physical servers, databases and computers.

Origin of Java and how is it different?

Java was developed by James Gosling and his team at Sun Microsystems (now part of Oracle Corporation) in the mid-1990s. The original goal of Java was to create a platform-independent language that could be used to write software for consumer electronics, such as televisions and set-top boxes.
Java is different from other programming languages in several key ways:
  1. Object-Oriented: Java is an object-oriented programming language, which means that it focuses on objects and the interaction between objects, rather than just the flow of a program.
  2. Platform Independent: Java code is compiled into an intermediate form called bytecode, which can be run on any platform that has a Java Virtual Machine (JVM) installed. This makes Java a “write once, run anywhere” language.
  3. Memory Management: Java has built-in memory management, which means that developers do not need to manually manage memory allocation and deallocation. This helps to reduce the number of memory-related errors and makes the language more efficient.
  4. Security: Java was designed with security in mind and includes features such as type checking, automatic memory management, and secure class loading, which make it more secure than many other programming languages.
    1. Robust: Java has robust error-handling features, including exceptions and type-checking, which make it more resilient to errors and bugs than some other programming languages.
    In summary, Java is a popular, object-oriented, platform-independent, memory-managed, secure, and robust programming language that is used for a wide range of applications, including web development, mobile development, and enterprise applications.

What findElements returns?

findElements is a method in the Selenium WebDriver API used to locate elements on a web page. This method returns a list of WebElement objects that match the specified criteria.
The list can be empty if no elements are found, or it can contain multiple elements if multiple elements match the criteria. For example, if you want to find all the elements with a specific tag name, you can use the following code:
List<WebElement> elements = driver.findElements(By.tagName("input"));
In this example, the findElements method is used with the By.tagName locator strategy to find all elements with the <input> tag. The resulting list of elements can then be used for further processing or testing.
It’s important to note that findElements is different from the findElement method, which returns a single WebElement. If you’re only interested in finding a single element, you should use findElement, as it will throw an exception if more than one element is found.

Difference between mutable and immutable objects in Java.

Mutable
Immutable
1.     The state and value of mutable objects can be changed after initialization.
The state and value of immutable objects cannot be changed after initialization.
2.     Mutable objects may or may not be thread safe.
Immutable objects are thread safe.
3.     get() and set() method are there to deal with the objects.
get() method is there to pass the value of a object.
4.     Getter and setter is used to create a mutable class.
Final class, private field, etc. is used to create immutable class.

Difference between Executable and non-executable file in Java.

 
Executable File
Non-executable File
1.     A file that can be directly executed by the computer and is capable of performing the indicated tasks according to the encoded instructions.
A file that is not directly executed by the CPU and is created for a specific task.
2.     Can be directly executed by the CPU.
Cannot be directly executed by the CPU.
3.     Can be compiled programs or scripts.
Can be audio, video, image, spreadsheet, etc.
 

Explain OOP concepts with Java.

OOP (Object-Oriented Programming) is a programming paradigm based on the concept of “objects”, which can contain data and behavior. The OOP concepts in Java are:
  1. Class: A class is a blueprint for creating objects (a particular data structure), providing initial values for state (member variables or attributes), and implementations of behavior (member functions or methods).
  2. Object: An object is an instance of a class. An object is a combination of data and behavior. Objects have state and behavior.
  3. Inheritance: Inheritance is a mechanism where a new class is derived from an existing class. The derived class inherits the properties and behaviors of the existing class and can add new properties and behaviors.
    1. Polymorphism: Polymorphism allows objects of different classes to be treated as objects of the same class. This enables the same method to be used on objects of different classes.
    2. Abstraction: Abstraction is a process of hiding the implementation details and showing only the functionality to the user. An abstract class is a class that cannot be instantiated and it requires subclasses to provide implementations for the abstract methods.
    3. Encapsulation: Encapsulation is the mechanism of wrapping data and behavior within a single unit, or object. Encapsulation helps to ensure that an object’s internal state is protected from external entities.
    In Java, all of these concepts are supported through various language constructs, such as classes, objects, inheritance, polymorphism, abstract classes, and interfaces. By utilizing these concepts, developers can create complex, modular, and scalable systems.

Write code for bubble sort

#include<stdio.h>
int main(){
    int array[100],n,c,d,swap;
    printf("Enter the number of elements\n");
    scanf("%d",&n);
    for(c=0;c<n;c++){
        scanf("%d",&array);
    }
    
    for(c=0;c<(n-1);c++){
      
        for(d=0;d<n-c-1;d++){
            
            if(array[d]>array[d+1]){
                swap =array[d];
                array[d]=array[d+1];
                array[d+1]=swap;
            }
        }
    }
    printf("Sorted array:\n");

    for(c=0;c<n-1;c++)
    printf("%d\n",array);
}
/*
output:
Enter the number of elements
4
11 72 22 
Sorted array:
11
22
72
*/

Write code for unique string.

Here is one way to check if a string contains only unique characters in Python:
def has_unique_chars(string):
    return len(string) == len(set(string))
This implementation uses the set data structure to store unique characters in the string. The length of the set is compared with the length of the original string. If they are equal, all characters in the string are unique and the function returns True. Otherwise, the function returns False.

Nagarro Solved

Automata Fixing

      

We Love to Support you

Go through our study material. Your Job is awaiting.

Recent Posts
Categories