Join Regular Classroom : Visit ClassroomTech

TCS Overall Interview Questions + Coding Solutions – codewindow.in

Hot Topics

TCS Solution

Technical Round

Explain any important feature of OOPs.

Important features 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.
  • Method Overriding: In place of inheritance if the parent class and child class both have the same method signature then child class method overrides the parent class method.
  • Method Overloading: If a class has more than one method with the same method name with variety of parameter list then method will be overloaded.
  • Object: Object is the reality of a class.
  • Class: Class is a blue print of similar type of objects.
  • Constructor: Constructor is a special member function that is automatically invoked at the time of object creation and does not have any return type.

Write a program to fetch first 10 even natural numbers.

#include<stdio.h>

int main() {
    
    for(int i=2;i&lt;=20;i+=2){
        printf(&quot;%d\n&quot;,i);
    }
    return 0;
}

/* 
OUTPUT:
2 4 6 8 10 12 14 16 18 20 
*/

Which programming language you most familiar with?

You should mention the programming language that you are most familiar with because interviewer will ask you from your familiar programming language.

What are the four pillars of OOPs?

Four pillars of OOPs are:
  1. Abstraction
  2. Encapsulation
  3. Inheritance
  4. Polymorphism

1) Esha ran 224m in 27 sec and Usha in 17 sec. At what distance did Esha cross Usha? 

2) A series 1234123441234441234444…..n what is the value on 200th position..? 

3)Star mark question: How many squares are there between 2011 to 2300 which follows 2013,2020,2027…….2300

  1. Without additional information, it is not possible to determine at what distance Esha and Usha crossed each other.
  2. The value on 200th position in the given series is 4.
  3. There are 45 squares between 2011 and 2300 that follow the pattern 2013, 2020, 2027, …, 2300.

What are the steps to connect to a database?

To connect a database with a Java program:
  1. Import packages
  2. Register the driver class
  3. Create connection with connection class object
  4. Create statement
  5. Execute the query
  6. Close connections

Write a query to find second highest salary.

SELECT name, MAX(salary) AS salary FROM employee WHERE salary <> (SELECT MAX(salary) FROM employee);
OR
Common Table Expression 
WITH T AS ( SELECT * DENSE_RANK() OVER (ORDER BY Salary Desc) AS Rnk FROM Employees) SELECT Name FROM T WHERE Rnk=2;

Is String immutable?

String is immutable in Java which means string can’t be modified or changed. It is immutable because if it is mutable then there will be a high security lapse by changing the reference value of the input.

What is encapsulation?

    Encapsulation is the method to hide the data in a single entity by
    protecting information from outside classes. Encapsulation can be
    obtained by using of access modifiers such as public, private, protected
    & default.

Explain inheritance.

Inheritance is a mechanism in which an object acquires properties from its parent object.

Is Java really platform independent?

Java is really platform independent language because of its bytecodes that can run on any system irrespective of its operating system.

Two candles, different densities, each burns for exactly 30 minutes. how do u measure 45 minutes.

 We can first burn a candle from one side which will take 30minutes to burn. For the second candle we can start burning it from both the sides. This way we can calculate extra 15minutes to burn the candle. By adding both the time of burning candle we can calculate 45 minutes.

Write a program for Fibonacci series.

#include<stdio.h>   
int main()    
{    
 int x=0,y=1,z,i;             
 for(i=1;i&lt;=10;i++) 
 {  
		 printf(&quot; %d&quot;,x);  
		  z=x+y;        
		  x=y;    
		  y=z;    
 		}  
 		
  	return 0;
	    
 }    

/*
OUTPUT
0 1 1 2 3 5 8 13 21 34
*/

Tell 3 java collections classes.

 Write a for loop program to print a line 10 times.

#include<stdio.h> 

int main()
{
    int n;
    printf("Enter the number of times you want to print lines\n");
    scanf("%d",&amp;n);
    for(int i=1;i&lt;=n;i++){
        printf(&quot;Line number %d\n&quot;,i);
    }

    return 0;
}
/*
INPUT:
n=10

OUTPUT
Line number 1
Line number 2
Line number 3
Line number 4
Line number 5
Line number 6
Line number 7
Line number 8
Line number 9
Line number 10
*/

What was the real life example of polymorphism?

A person can have different relationships with different people.

What is an array?

An array is a linear data structure that can store same data types in
contiguous memory allocation..

Give algorithm for factorial of c program?

  • Take an integer from the user to find the factorial
  • Read the integer and assign it to a variable
  • From the value of the integer up to 1, multiply each digit and update the final value
  • The final value at the end of all the multiplication till 1 is the factorial

Nagarro Solved

Automata Fixing

      

We Love to Support you

Go through our study material. Your Job is awaiting.

Recent Posts
Categories