DEV Community

cloudytech147
cloudytech147

Posted on

Crack Infosys Interview Questions

Infosys is an Indian MNC that is among the most prominent IT players in the world. It could be a dream company for many Indian developers and an excellent platform to start your career in IT.

Infosys Interview Questions

List of Infosys Interview Questions

Here I've compiled with top question asked in infosys interview for developers. Know the answers from this blog on Infosys Interview Questions.

  1. Name some high-level programming languages.
  2. C is sometimes considered a low-level programming language. Why so?
  3. What is a preprocessor in C?
  4. Name basic OOPs concepts.
  5. What is inheritance? Name its types.
  6. Please enumerate the various types of inheritance.
  7. What are tokens in C++?
  8. What is the difference between multi-level and multiple inheritances?
  9. Give some differences between C++ and Java.
  10. How encapsulation and abstraction are complementary?
  11. What are arrays?
  12. What is a pointer in C?
  13. Give some differences between C and C++.
  14. What is a NULL pointer?
  15. Give logic to swap two numbers without using a temporary variable.

Conclusion

In this article, we have provided the top Infosys technical interview questions. After reading all the Infosys technical interview questions, you will notice that most of the questions are from C and C++, which also includes OOPs concept with data structure because these are the basis of programming languages, and a developer should have knowledge of basic technical stuff.

Top comments (5)

Collapse
 
sachiravi profile image
sachiravi • Edited
LocalDate orderDate = LocalDate.parse(orderDate###nput, DateT###meFormatter.ofPattern("yyyy-MMM-dd"));
        ###nput.close();

        ###f (###sVal###dPhoneNumber(orderDeta###ls.getPhoneNo())) {
            Str###ng order###d = orderDeta###ls.generateOrder###d();

            ###nt del###veryDays = orderDeta###ls.get###sOneDayDel###very().equals###gnoreCase("Yes") ? 1 : 7;
            LocalDate del###veryDate = orderDate.plusDays(del###veryDays);

            System.out.pr###ntln("Your order w###ll be del###vered on " + del###veryDate.format(DateT###meFormatter.ofPattern("dd'th' MMM,yyyy")) + " and your order###d ###s: " + order###d);
        } else {
            System.out.pr###ntln("Phone number ###s ###nval###d!");
        }
    }

    pr###vate stat###c boolean ###sVal###dPhoneNumber(Long phoneNumber) {
        // ###mplement your phone number val###dat###on log###c here
        // Th###s example just checks for a spec###f###c number of d###g###ts
        return phoneNumber.toStr###ng().length() == 10;
}



Str###ngBu###lder order###d = new Str###ngBu###lder();
        ###f (###sOneDayDel###very.equals###gnoreCase("Yes")) {
            order###d.append("#Y");
        } else {
            order###d.append("N");
        }
        order###d.append((###nt) ordered###temType.charAt(0)) // ASC###### code of f###rst character of ordered###temType
                .append((###nt) ordered###tem.charAt(1)) // ASC###### code of second character of ordered###tem
                .append(orderPr###ce.###ntValue())
                .append(orderQuant###ty)
                .append(phoneNo);
        return order###d.toStr###ng();
    }
Enter fullscreen mode Exit fullscreen mode
Collapse
 
xmachli profile image
XMachli

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Scanner;

class Solution {

public static void main(String[] args) {
    Scanner input = new Scanner(System.in);

    // Read input values
    Long phoneNo = input.nextLong();
    String orderedItemType = input.next();
    String orderedItem = input.next();
    Double orderPrice = input.nextDouble();
    Integer orderQuantity = input.nextInt();
    String isOneDayDelivery = input.next();
    input.nextLine(); // consume the newline
    String deliveryAddress = input.nextLine();
    String orderDateInput = input.next();

    // Parse the order date
    LocalDate orderDate = null;
    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
    try {
        orderDate = LocalDate.parse(orderDateInput, formatter);
    } catch (Exception e) {
        System.out.println("Invalid date format!");
        input.close();
        return;
    }

    input.close();

    // Create OrderDetails object
    OrderDetails orderDetails = new OrderDetails(phoneNo, orderedItemType, orderedItem, orderPrice, orderQuantity, isOneDayDelivery, deliveryAddress);

    // Determine delivery date
    LocalDate deliveryDate;
    if (orderDetails.getIsOneDayDelivery().equalsIgnoreCase("Yes") || orderDetails.getIsOneDayDelivery().equalsIgnoreCase("Y")) {
        deliveryDate = orderDate.plusDays(1);
    } else {
        deliveryDate = orderDate.plusDays(7);
    }

    // Generate order ID
    String orderId = OrderDetails.generateOrderId(orderDetails);

    // Format and print the delivery date and order ID
    DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("dd MMM, yyyy");
    System.out.printf("Your order will be delivered on %s and your orderid is: %s%n", deliveryDate.format(outputFormatter), orderId);
}
Enter fullscreen mode Exit fullscreen mode

}

class OrderDetails {
private Long phoneNo;
private String orderedItemType;
private String orderedItem;
private Double orderPrice;
private Integer orderQuantity;
private String isOneDayDelivery;
private String deliveryAddress;

public OrderDetails() {}

public OrderDetails(Long phoneNo, String orderedItemType, String orderedItem, Double orderPrice, Integer orderQuantity, String isOneDayDelivery, String deliveryAddress) {
    this.phoneNo = phoneNo;
    this.orderedItemType = orderedItemType;
    this.orderedItem = orderedItem;
    this.orderPrice = orderPrice;
    this.orderQuantity = orderQuantity;
    this.isOneDayDelivery = isOneDayDelivery;
    this.deliveryAddress = deliveryAddress;
}

public Long getPhoneNo() {
    return phoneNo;
}

public void setPhoneNo(Long phoneNo) {
    this.phoneNo = phoneNo;
}

public String getOrderedItemType() {
    return orderedItemType;
}

public void setOrderedItemType(String orderedItemType) {
    this.orderedItemType = orderedItemType;
}

public String getOrderedItem() {
    return orderedItem;
}

public void setOrderedItem(String orderedItem) {
    this.orderedItem = orderedItem;
}

public Double getOrderPrice() {
    return orderPrice;
}

public void setOrderPrice(Double orderPrice) {
    this.orderPrice = orderPrice;
}

public Integer getOrderQuantity() {
    return orderQuantity;
}

public void setOrderQuantity(Integer orderQuantity) {
    this.orderQuantity = orderQuantity;
}

public String getIsOneDayDelivery() {
    return isOneDayDelivery;
}

public void setIsOneDayDelivery(String isOneDayDelivery) {
    this.isOneDayDelivery = isOneDayDelivery;
}

public String getDeliveryAddress() {
    return deliveryAddress;
}

public void setDeliveryAddress(String deliveryAddress) {
    this.deliveryAddress = deliveryAddress;
}

public static String generateOrderId(OrderDetails orderDetails) {
    StringBuilder orderId = new StringBuilder();
    boolean isOneDayDelivery = orderDetails.getIsOneDayDelivery().equalsIgnoreCase("Y") || orderDetails.getIsOneDayDelivery().equalsIgnoreCase("Yes");

    if (isOneDayDelivery) {
        orderId.append("Y");
        orderId.append((int) orderDetails.getOrderedItemType().charAt(orderDetails.getOrderedItemType().length() - 1));
    } else {
        orderId.append("N");
        orderId.append((int) orderDetails.getOrderedItemType().charAt(0));
    }
    orderId.append((int) orderDetails.getOrderedItemType().charAt(1));
    orderId.append(orderDetails.getOrderPrice().intValue());
    orderId.append(orderDetails.getOrderQuantity());
    orderId.append(orderDetails.getPhoneNo());

    return orderId.toString();
}
Enter fullscreen mode Exit fullscreen mode

}

Collapse
 
oggy2378 profile image
Oggy

function(int k,int nums){
char[] s=String.valueof(nums).toCharArray();
int cnt
for(i=0-->N){
int div=getNo(k,i,s);
if(nums%div==0 && div!=0){
cnt++
return cnt

getNO(int start,[]s,k)
num=0;
while(K>0){
num=num*10;
num=(S[start]-'0')+num;
start++;
k--;
}

Collapse
 
jashwant_verma_a789fdd5bc profile image
jashwant Verma

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Scanner;

@SuppressWarnings("all")
class Solution {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
OrderDetails orderDetails = new OrderDetails(
input.nextLong(), input.next(), input.next(),
input.nextDouble(), input.nextInt(), input.next(), input.next()
);
String orderDateInput = input.next();

    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MMM-dd");
    LocalDate orderDate = LocalDate.parse(orderDateInput, formatter);
    input.close();

    if (isValidPhoneNumber(orderDetails.getPhoneNo())) {
        String orderId = OrderDetails.generateOrderId(orderDetails);
        LocalDate deliveryDate;
        if (orderDetails.getIsOneDayDelivery().equalsIgnoreCase("Yes") || orderDetails.getIsOneDayDelivery().equalsIgnoreCase("Y")) {
            deliveryDate = orderDate.plusDays(1);
        } else {
            deliveryDate = orderDate.plusDays(7);
        }

        System.out.println("Your order will be delivered on " + 
                           deliveryDate.getDayOfMonth() + "th " + 
                           deliveryDate.getMonth() + ", " + 
                           deliveryDate.getYear() + " and your order id is: " + orderId);
    } else {
        System.out.print("Phone number is invalid!");
    }
}

private static boolean isValidPhoneNumber(Long phoneNumber) {
    String phoneStr = phoneNumber.toString();
    if (phoneStr.length() != 10) {
        return false;
    }

    char firstChar = phoneStr.charAt(0);
    for (int i = 1; i < phoneStr.length(); i++) {
        if (phoneStr.charAt(i) != firstChar) {
            return true;
        }
    }
    return false;
}
Enter fullscreen mode Exit fullscreen mode

}

class OrderDetails {
private Long phoneNo;
private String orderedItemType;
private String orderedItem;
private Double orderPrice;
private Integer orderQuantity;
private String isOneDayDelivery;
private String deliveryAddress;

public OrderDetails() { }

public OrderDetails(Long phoneNo, String orderedItemType, String orderedItem, Double orderPrice, Integer orderQuantity, String isOneDayDelivery, String deliveryAddress) {
    this.phoneNo = phoneNo;
    this.orderedItemType = orderedItemType;
    this.orderedItem = orderedItem;
    this.orderPrice = orderPrice;
    this.orderQuantity = orderQuantity;
    this.isOneDayDelivery = isOneDayDelivery;
    this.deliveryAddress = deliveryAddress;
}

public Long getPhoneNo() {
    return phoneNo;
}

public void setPhoneNo(Long phoneNo) {
    this.phoneNo = phoneNo;
}

public String getOrderedItemType() {
    return orderedItemType;
}

public void setOrderedItemType(String orderedItemType) {
    this.orderedItemType = orderedItemType;
}

public String getOrderedItem() {
    return orderedItem;
}

public void setOrderedItem(String orderedItem) {
    this.orderedItem = orderedItem;
}

public Double getOrderPrice() {
    return orderPrice;
}

public void setOrderPrice(Double orderPrice) {
    this.orderPrice = orderPrice;
}

public Integer getOrderQuantity() {
    return orderQuantity;
}

public void setOrderQuantity(Integer orderQuantity) {
    this.orderQuantity = orderQuantity;
}

public String getIsOneDayDelivery() {
    return isOneDayDelivery;
}

public void setIsOneDayDelivery(String isOneDayDelivery) {
    this.isOneDayDelivery = isOneDayDelivery;
}

public String getDeliveryAddress() {
    return deliveryAddress;
}

public void setDeliveryAddress(String deliveryAddress) {
    this.deliveryAddress = deliveryAddress;
}

public static String generateOrderId(OrderDetails orderDetails) {
    StringBuilder orderId = new StringBuilder();
    String itemType = orderDetails.getOrderedItemType();
    String item = orderDetails.getOrderedItem();

    if (orderDetails.getIsOneDayDelivery().equalsIgnoreCase("Yes") || orderDetails.getIsOneDayDelivery().equalsIgnoreCase("Y")) {
        orderId.append("Y");
        orderId.append("#");
        orderId.append((int)itemType.charAt(itemType.length() - 1));
        orderId.append((int)item.charAt(1));
    } else {
        orderId.append("N");
        orderId.append((int)itemType.charAt(0));
        orderId.append((int)item.charAt(1));
    }

    orderId.append(orderDetails.getOrderPrice());
    orderId.append(orderDetails.getOrderQuantity());
    orderId.append(orderDetails.getPhoneNo());

    return orderId.toString();
}
Enter fullscreen mode Exit fullscreen mode

}

Collapse
 
slowcheetah profile image
SlowCheetah

import math

def is_perfect_square(n):
sqrt_n = int(math.sqrt(n))
return sqrt_n * sqrt_n == n

def find_last_three_digits_factorial(n):
factorial = math.factorial(n)
factorial_str = str(factorial)

# Find the index of the last non-zero digit
non_zero_index = next(i for i in range(len(factorial_str) - 1, -1, -1) if factorial_str[i] != '0')

# Extract the last three digits
last_three_digits = factorial_str[max(0, non_zero_index - 2):non_zero_index + 1]

return int(last_three_digits)
Enter fullscreen mode Exit fullscreen mode

def process_input_string(input_str):
input_numbers = [int(num) for num in input_str.split(',')]

perfect_squares = [num for num in input_numbers if is_perfect_square(num)]

if not perfect_squares:
return -1

output = [find_last_three_digits_factorial(square) for square in perfect_squares]

return ', '.join(map(str, output))

Enter fullscreen mode Exit fullscreen mode




Example usage

input_str = "2,4,6,9,35,100"
output_result = process_input_string(input_str)
print("Output:", output_result)