Technical Interview Questions and Answers :: TCS
- Select All
- SQL
- Java
- C++
- WebMethod
- Informatica
- C
- DBMS
- Operating System
- Soft. Engineering
- Data Structure
- Networking
- Hadoop
- HR Question in TR
101 / 158
No Discussion on this question yet!
102 / 158
An exception is a problem that arisesduring excecution. Checked exceptions are the exceptions that gets checked at the compile time. Unchecked exceptions are not checked at compile time, in Java all exceptions are unchecked exceptions.
103 / 158
Some peculiar problems other than logic or syntax errors, they are known as exceptions. Exceptions are run-time anomalies or unusual conditions that a program may encounter while executing. Anomalies might include the condition such a division by zero, array outside of bound etc.
104 / 158
Exception handling mechanism is basically built upon through keywords namely try, catch, and throw. The keyword try is used to preface a block of statements which may generate an exception. This block of statements is known as try block. When an exception is detected, it is thrown using a throw statement in the try block. A catch statement is defined by the keyword catch “catches†the exception thrown by the throw statement in the try block.
105 / 158
The purpose of exception handling mechanism is to provide means to detect and report an “exception circumstanceâ€. So that appropriate action can be taken. The mechanism suggests a separate error handling code that performs the following tasks.
1. Find the problem (hit the exception).
2. Inform than an error has occurred (throw the exception).
3. Receives the error information (catch the exception).
4. Take corrective action (handle the exception).
106 / 158
Overloading -> enables a handle to gain control and do some work on each access to an object.
107 / 158
Method Overloading:
A method with changed formal parameters will lead to implementing method overloading.
int calculateSum(int i,int j)
float calculateSum(float i,int j)
double calculateSum(double i,int j)
float calculateSum(int i,float j)
Method Overriding:
The method with the same signature but with changed implementation lead to method overriding and that can occur in a parent child relation of classes. A method defined in parent class can be overridden in its child class with different implementation from its base class.
1. Pointers are supported in C++ while not in Java. The memory management is done automatically with help of part of JVM called Garbage Collector.
2. Multiple inheritance is not supported in Java but supported in C++.
3. There are no structures and unions in Java.
4. There is no scope resolution operator in Java (::).
5. There are no destructors in Java like C++.
6. There is no virtual keyword in Java because all non-static method use dynamic binding.
108 / 158
Syntax:
void operator delete(void *p)
{
/*free memory pointed to by p. the destructor is called automatically.*/
}
The delete function receives a pointer to the region of memory to be freed. It then releases the previously allocated memory back to the system. When an object is deleted, its destructor is automatically called.
109 / 158
Syntax:
void *operator new (size_t size)
{
/*performs the allocation operation.
The constructor is called automatically.
returns the pointer to memory*/
}
size_t - It is a defined type capable of containing the largest single piece of memory that can be allocated.
Size - It contains the number of bytes needed to hold the object being allocated.
When we allocate an object using new, the object’s constructor is automatically called.
110 / 158
Two or more functions can share the same name that perform a variety of different tasks as long as their parameter declarations are different. The functions that share the same name are said to be overloaded, and the process is referred to as function overloading.
TCS technical interview experience, TCS technical interview question, TCS technical interview questions, TCS technical interview questions and answers, TCS technical interview questions for cse, TCS technical interview questions for freshers, TCS technical interview questions on c, TCS technical questions and answers, TCS technical round, TCS technical round questions, TCS technical round questions for ece, TCS telephonic interview