Serole Technologies
Cosmic Byte Interview Questions and Answers
Q1. What are checked and unchecked exceptions
Checked exceptions are checked at compile-time while unchecked exceptions are not.
Checked exceptions are those that are checked at compile-time and must be handled or declared in the method signature.
Unchecked exceptions are those that are not checked at compile-time and do not need to be handled or declared in the method signature.
Examples of checked exceptions include IOException, ClassNotFoundException, and SQLException.
Examples of unchecked exceptions include NullPointerE...read more
Q2. What is object and what is class?
An object is an instance of a class. A class is a blueprint or template for creating objects.
A class defines the properties and behaviors of objects
An object is created from a class using the 'new' keyword
Multiple objects can be created from a single class
Classes can inherit properties and behaviors from other classes
Example: Class - Car, Object - Honda Civic
Q3. Difference between string buffer and string builder
String buffer is synchronized and thread-safe while string builder is not.
String buffer is slower than string builder due to synchronization.
String builder is faster but not thread-safe.
String buffer is preferred for multi-threaded applications.
String builder is preferred for single-threaded applications.
Both classes are used for manipulating strings efficiently.
Q4. How to use try, catch and finally?
try-catch-finally is used for handling exceptions in code.
try block contains the code that may throw an exception
catch block catches the exception thrown by try block
finally block contains code that will be executed regardless of exception
Multiple catch blocks can be used for handling different types of exceptions
Q5. Difference between arraylist and array?
ArrayList is a dynamic data structure while Array is a static data structure.
ArrayList can grow or shrink dynamically while Array has a fixed size.
ArrayList can store objects of any type while Array can only store elements of the same data type.
ArrayList provides built-in methods for insertion, deletion, and searching while Array does not.
Example: ArrayList
names = new ArrayList (); String[] namesArray = new String[5]; Example: names.add("John"); names.add("Jane"); namesArray[0...read more
Q6. Explain any 2 oops concepts
Encapsulation and Inheritance are two important OOPs concepts.
Encapsulation is the process of binding data and functions that manipulate that data together in a single unit, called a class.
Inheritance is the process of creating a new class by inheriting properties and methods from an existing class.
Encapsulation helps in data hiding and abstraction, which makes the code more secure and easy to maintain.
Inheritance helps in code reusability and saves time and effort in writing...read more
Q7. Usage of final keyword
Final keyword is used to declare a constant value that cannot be changed.
Final keyword can be used with variables, methods, and classes.
Final variables must be initialized at the time of declaration or in constructor.
Final methods cannot be overridden by subclasses.
Final classes cannot be extended by other classes.
Final keyword is also used in try-with-resources statement to declare resources that should be closed after use.
Top Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month