0% found this document useful (0 votes)
78 views

Interview Prepration

Here are the steps to capitalize the first letter of the input string and print it: 1. Define a string variable to hold the input: String str = "helloworld"; 2. Extract the first 5 characters of the input string using substring() and store it in a separate variable: String firstFive = str.substring(0, 5); 3. Capitalize the first letter of the extracted string by: - Getting the first character as a substring from index 0 to 1 - Converting it to uppercase using toUpperCase() - Concatenating it with the remaining substring from index 1 String capitalized = firstFive.substring(0, 1).toUpperCase() +

Uploaded by

Vaibhav More
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views

Interview Prepration

Here are the steps to capitalize the first letter of the input string and print it: 1. Define a string variable to hold the input: String str = "helloworld"; 2. Extract the first 5 characters of the input string using substring() and store it in a separate variable: String firstFive = str.substring(0, 5); 3. Capitalize the first letter of the extracted string by: - Getting the first character as a substring from index 0 to 1 - Converting it to uppercase using toUpperCase() - Concatenating it with the remaining substring from index 1 String capitalized = firstFive.substring(0, 1).toUpperCase() +

Uploaded by

Vaibhav More
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Introduction:

"Hello, my name is Sushant Hirave and I'm originally from Kolhapur. Currently living in
Pune. I pursued my Bachelor's degree in Mechanical Engineering from SKN Sinhgad
Institute of Technology, Lonavala. After that, I completed a Postgraduate diploma in
CDAC where I learnt Java programming language along with MySQL & ReactJs. In my
free time, I enjoy reading and expanding my knowledge on various topics. I'm a
passionate about finding creative solutions to complex problems. I believe in
continuously learning and developing new skills to improve myself both personally
and professionally."

1.Object
Any entity that has state and behaviour is known as an object. For example, a chair,
pen, table, keyboard, bike, etc. It can be physical or logical.

An Object can be defined as an instance of a class. An object contains an address and


takes up some space in memory. Objects can communicate without knowing the
details of each other's data or code. The only necessary thing is the type of message
accepted and the type of response returned by the objects.

Example: A dog is an object because it has states like color, name, breed, etc. as well
as behaviors like wagging the tail, barking, eating, etc.

2.Class
Collection of objects is called class. It is a logical entity.

A class can also be defined as a blueprint from which you can create an individual
object. Class doesn't consume any space.

3.Inheritance
When one object acquires all the properties and behaviors of a parent object, it is known
as inheritance. It provides code reusability. It is used to achieve runtime polymorphism.

4.Polymorphism
If one task is performed in different ways, it is known as polymorphism. For example: to
convince the customer differently, to draw something, for example, shape, triangle,
rectangle, etc.
In Java, we use method overloading and method overriding to achieve polymorphism.

Another example can be to speak something; for example, a cat speaks meow, dog
barks woof, etc.

5.Abstraction
Hiding internal details and showing functionality is known as abstraction. For example
phone call, we don't know the internal processing.

In Java, we use abstract class and interface to achieve abstraction.

6.Encapsulation
Binding (or wrapping) code and data together into a single unit are known as
encapsulation. For example, a capsule, it is wrapped with different medicines.

A java class is the example of encapsulation. Java bean is the fully encapsulated class
because all the data members are private here.

GET:

• Used for retrieving a resource from the server.


• Does not have a request body and all parameters are sent in the URL.
• Idempotent, which means that making the same GET request multiple times will
not change the resource.
• Responses can be cached by the client or intermediary caches.

POST:

• Used for creating a new resource on the server or submitting data to be


processed.
• Has a request body that contains the data to be submitted.
• Not idempotent, which means that making the same POST request multiple
times will result in multiple resources being created.
• Responses cannot be cached by the client or intermediary caches.

PUT:

• Used for updating an existing resource on the server.


• Has a request body that contains the data to be updated.
• Idempotent, which means that making the same PUT request multiple times will
result in the same resource being updated.
• Responses cannot be cached by the client or intermediary caches.

Request Request
Method Purpose Body Idempotent Caching

GET Retrieve a resource None Yes Yes

POST Create a resource or Submit data Yes No No

PUT Update a resource Yes Yes No

What is a REST API?

REST (Representational State Transfer) is an architectural style for designing web


services. A RESTful API is an API that follows the principles of the REST architecture.

In a REST API, each resource is identified by a unique URI (Uniform Resource Identifier)
and is accessed using a set of standard HTTP methods such as GET, POST, PUT, and
DELETE.

The main characteristics of a RESTful API are:

1. Stateless: Each request sent from a client to the server must contain all the
necessary information for the server to understand and process the request.
The server should not store any client context.
2. Client-Server Architecture: The client and server are separated and interact with
each other through a uniform interface.
3. Cacheable: The server response must explicitly indicate whether the response
can be cached or not.
4. Layered System: A client can interact with a RESTful API through an
intermediary, such as a load balancer, without knowing the details of the
intermediary.
5. Uniform Interface: A set of standard HTTP methods such as GET, POST, PUT,
DELETE should be used to access resources. Resources should be identified by
URIs, and the responses should be in a standard format, such as JSON or XML.

RESTful APIs are widely used in web applications, mobile applications, and other client-
server interactions because of their simplicity, scalability, and flexibility.
Question

Input: helloworld

output : Hello

Answer:

public class Pg1 {

public static void main(String[] args) {

String str = "helloworld";

String firstFive = str.substring(0, 5); // extract first five characters

String capitalized = firstFive.substring(0, 1).toUpperCase() + firstFive.substring(1);


// capitalize first letter

System.out.println(capitalized); // output "Hello"

You might also like