TCS
UST Interview Questions and Answers
Q1. What is compile time polymorphism and runtime polymorphism?
Compile time polymorphism is achieved through method overloading, while runtime polymorphism is achieved through method overriding.
Compile time polymorphism is also known as static polymorphism.
It is achieved by having multiple methods in the same class with the same name but different parameters.
Example: method overloading in Java.
Runtime polymorphism is also known as dynamic polymorphism.
It is achieved by having a method in a superclass and a method with the same signature ...read more
Q2. how to handle exception in spring boot?
Exceptions in Spring Boot can be handled using try-catch blocks, @ExceptionHandler annotation, and global exception handling.
Use try-catch blocks to handle exceptions within a specific method.
Use @ExceptionHandler annotation to handle exceptions at the controller level.
Implement a global exception handler using @ControllerAdvice and @ExceptionHandler annotations.
Customize error responses using ResponseEntityExceptionHandler.
Use @ResponseStatus annotation to specify the HTTP s...read more
Q3. what is a classLoader?
A classLoader is a part of the Java Runtime Environment that dynamically loads Java classes into the Java Virtual Machine.
ClassLoader is responsible for loading classes at runtime in Java.
It follows a delegation hierarchy to search for classes.
There are different types of class loaders like Bootstrap, Extension, and System class loaders.
Custom class loaders can be created to load classes from different sources like network or database.
Q4. what is Polymorphism?
Polymorphism is the ability of an object to take on multiple forms.
Polymorphism allows objects of different classes to be treated as objects of a common superclass.
There are two types of polymorphism: compile-time (method overloading) and runtime (method overriding).
Example: Animal superclass with Dog and Cat subclasses, both overriding the makeSound() method.
Q5. What is constructor?
Constructor is a special method that is used to initialize objects in Java.
Constructor has the same name as the class name
It does not have a return type
It can be overloaded
It is called automatically when an object is created
Example: public class Car { public Car() { // constructor code here } }
Q6. what is Truncate
Truncate is a SQL command used to delete all rows from a table without logging the individual row deletions.
Truncate is a DDL (Data Definition Language) command in SQL.
It is used to quickly delete all rows from a table, but it does not log individual row deletions.
Truncate is faster than using the DELETE command, as it does not generate individual row deletion logs.
Truncate also resets any auto-incrementing keys in the table.
Example: TRUNCATE TABLE table_name;
More about working at TCS
Top HR Questions asked in UST
Interview Process at UST
Top Java Developer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month