Вы находитесь на странице: 1из 7

JAVA

1. What is Method overloading in Java?


It is the feature which allows a class to have two or more method having same name with different
argument list.
Argument list may differ in
1. Number of parameter
2. Order of parameter
3. Data type of parameter
2. Is method overloading possible by changing the return type of method?
Yes
3. What is the use of final key word in java?
Final variable - If you make any variable as final, you cannot change the value of final variable (It
will be constant).
Final method - If you make any method as final, you cannot override it.
Final class - If you make any class as final, you cannot extend it.
4. Is final method inherited?
Yes final method can be inherited bur cant override it.
5. Explain different ways of creating a thread
1) By extending the class Thread
2) By implementing the interface Runnable
6. Explain difference between wait and sleep method
Both makes current thread into Not Runnable state.
Wait()
It is a method of object class. It is called on a object not on a thread.
Object should be in synchronized block
Sleep()
It is a static method of thread class. It is called on a Thread.
7. What are the basic interfaces of Java Collections Framework?
Collections
- Set
o Sorted Set
- List
- Queue
- DQueue
Map
- Sorted Map
8. What is difference between Fail-Safe vs Fail-Fast Iterator?
Fail Safe Iterator Takes copy of the internal data structure of the object before iterating. It is
guaranteed to not to throw concurrent modification exception.
Example : CopyOnWriteArrayList, ConcurrentHashMap
Fail Fast Iterator It wont take copy of the object before iterating. Concurrent modification
exception is thrown when the internal data structure is modified while iterating through the
collection.

Example : HashMap,Vector,ArrayList,HashSet

9. What is the difference between HashSet and TreeSet?


Both doesnt allow duplicate elements.
Treeset Orders the element in ascending order by default.
Hashset Doesnt maintain any order.
10. What precaution has to be considered when using user-defined object as a key for HashMap?
It is best practice to override hascode and equals methods for the classes used as a key.
Spring:
1. What are benefits of Spring Framework?
1. Dependency injection.
2. Works on POJO. Easy to inject
3. Enhances modularity. Provides more readable codes.
4. Provides loose coupling between different modules.
5. Effective in organizing the middle-tier applications.

2. What are the different types of IoC (dependency injection)?


6. Constructor Injection
7. Setter Injection
3. What is Spring Java-Based Configuration?
Java based configuration is done using Annotations.
@Configuration
@Bean
4. What are the different scopes a Spring Bean can have and what is the default?
Singleton Single instance per spring IOC container (DEFAULT)
Request HTTP Request
Prototype - Any number of object instances
Session HTTP Session
Global Session- Global HTTP Session
5. How Spring Beans are identified in annotation based configuration?
We need to add the below configuration in application context.
<context:annotation-config/>
Hibernate:
1. Advantage of Hibernate over JDBC
Hibernate is database independent.
Hibernate deals with Object. Each DB tables has a Object associated with it in hibernate
configuration.
2. What are the states of object in hibernate?
Transient Whenever a POJO class is created, it will be in transient state (Before Session)

Persistent Persistence instance has a representation in a database. It might be ether saved or


loaded. (In Session)
Detached Object that has been already persisted. (Session Closed)
Web Service:
1. Can you name different kinds of web services?
WSDL/SOAP based web service
RESTFul web services
2. What is a difference between RESTful web services and SOAP web services?
RESTFul
Uses URI to expose business logic
Supports plain data, HTML, XML, JSON
Requires less bandwidth
SOAP
Uses service interface to expose business logic
Communication through XML data format
Requires more bandwidth
3. Which HTTP methods are supported by RestFull web services ?
GET = The GET method retrieves specific information from the server as identified by the request
URI.
PUT = The PUT method requests that the message body sent with the request be stored under
the location provided in the HTTP message.
DELETE = The DELETE method deletes the specified resources.
POST = The POST method modifies data on the server from which a request was sent.
HEAD = The HEAD method is similar to the GET method except the message body is not
returned in the response.
4. What is the difference between POST and PUT?
The PUT method requests that the message body sent with the request be stored under the
location provided in the HTTP message.
The POST method modifies data on the server from which a request was sent.

Design
1. How will you design Student details site? Student, Subject and Marks are

the three Entities to be considered?

Detailed Flow Diagram


The design of student details system includes the design of home page which
provides the way for students, staff, and administrator to access the
application. Every user has a username and password provided by the
administrator. The home page contains login form through which existing user
can login or new user can register into the system.
Based on the user type, user will redirected to the corresponding page for
which he has access to.
Start

Home Page
Login fail
Login
Login
Success

Admin

Create/Modify
User Details

Staff

Create/Modify
Subject Details

Student

View/Update
Personal details

Use case
View / Update Details

Student

Enroll Subjects

View Marks

Staff

Enter/Update Subject
Details

Enter/Update Marks Details

Web Admin

New user creation

Object Definition
Student Object
Name
Name
Address
Phone
Email
Roll Number

Type
String
String
String
String
Long

Subject Object
Name
Subject Id
Address
Phone
Email
Roll Number

Type
String
String
String
String
Long

Marks Object
Name
Name
Address
Phone
Email
Roll Number

Type
String
String
String
String
Long

User Object
Name
Username
Password

2.

Type
String
String

How will you design Online Quiz site? Add timer after each question?

Entities
Lets define the entities of online quiz. (Refer below diagram)

Administrator

Student

Faculty

Online Quiz System

Use case
View Reports

Administrator
Registration

View Reports
Faculty
Set Questions and Timer

Take Exams

Student
Object Definition

View Reports

Student
Name
Student Id
Student Name

Type
String
String

View
View
Reports
Reports

Faculty
Faculty
Administrator

Insert
Insert
Questions
Questions
Registration

User
Name
Username
Password

Type
String
String

Question
Name
Question Id
Question Name
Timer

Type
String
String
Long

Answer
Name
Answer Id
Question Id
Answer
Is_Correct_Answer

Type
String
String
String
Boolean

Student Response
Name
Student Id
Question Id
Answer Id

Type
String
String
String

Mark
Name
Student Id
Question Id
Mark
Grade

Type
String
String
String
String

Вам также может понравиться