Developer 2
Developer 2 Interview Questions and Answers
Q1. What is the difference between sealed class and ENUM
Sealed classes allow for controlled inheritance, while enums define a fixed set of constants.
Sealed classes restrict inheritance to a specific set of subclasses.
Enums represent a fixed set of named constants, often used for categorical data.
Example of sealed class: 'sealed class Shape { class Circle : Shape; class Square : Shape; }'
Example of enum: 'enum Color { Red, Green, Blue }'
Sealed classes can have state and behavior, while enums are typically stateless.
Q2. Status codes of GET, POST, PUT, PATCH, DELETE
Status codes for HTTP methods
GET - 200 OK, 404 Not Found
POST - 201 Created, 400 Bad Request
PUT - 200 OK, 204 No Content
PATCH - 200 OK, 204 No Content
DELETE - 200 OK, 204 No Content
Q3. How to implement AIDL in android application
AIDL enables communication between different Android components, especially across processes.
Define AIDL interface in a .aidl file, e.g., 'IMyAidlInterface.aidl'.
Implement the AIDL interface in a Service class, e.g., 'MyAidlService'.
Bind the service in the client activity using 'bindService()'.
Use the generated binder to call methods defined in the AIDL interface.
Ensure proper permission handling for inter-process communication.
Q4. Different Types of HTTP methods
HTTP methods are used to indicate the desired action to be performed on a resource.
GET: Retrieve data from a server
POST: Send data to a server to create a new resource
PUT: Update an existing resource on a server
DELETE: Remove a resource from a server
PATCH: Partially update an existing resource on a server
Q5. What is data class and write code
A data class is a special class in programming that holds data and automatically generates methods like equals(), hashCode(), and toString().
Data classes are primarily used to store data without much boilerplate code.
In Python, a data class can be created using the @dataclass decorator.
Example in Python: @dataclass class Point: x: int; y: int.
In Kotlin, data classes are defined using the 'data' keyword.
Example in Kotlin: data class User(val name: String, val age: Int).
Q6. OOPs concepts and types of polymorphism
OOP concepts include encapsulation, inheritance, and polymorphism, with polymorphism allowing methods to do different things based on context.
Encapsulation: Bundling data and methods that operate on the data within one unit (class). Example: A class 'Car' with properties like 'color' and methods like 'drive()'.
Inheritance: Mechanism where a new class inherits properties and methods from an existing class. Example: 'ElectricCar' inherits from 'Car'.
Polymorphism: Ability for di...read more
Share interview questions and help millions of jobseekers 🌟
Q7. Write program to sort the list array
This program sorts an array of strings in alphabetical order using a simple sorting algorithm.
Use built-in sorting functions like `sort()` in Python: `my_list.sort()`.
For custom sorting, use a key function: `sorted(my_list, key=len)` sorts by string length.
Example: Sorting an array of strings: `['banana', 'apple', 'cherry']` results in `['apple', 'banana', 'cherry']`.
Q8. Write to program to reverse the string
Developer 2 Jobs
Interview Questions of Similar Designations
Interview experiences of popular companies
Calculate your in-hand salary
Confused about how your in-hand salary is calculated? Enter your annual salary (CTC) and get your in-hand salary
Reviews
Interviews
Salaries
Users/Month