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

Sapphire Interview Questions

Uploaded by

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

Sapphire Interview Questions

Uploaded by

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

Introduce

1) Java Features:
 Simple.
 Object-Oriented.
 Platform Independent.
 Portable.
 Robust.
 Secure.
 Interpreted.
 Multi-Threaded.

2) Why java is platform independent:

Java is platform-independent because it compiles code into bytecode, which is executed by platform-
specific Java Virtual Machines (JVMs). This "Write Once, Run Anywhere" approach enables Java
programs to run on various platforms without modification, ensuring portability and consistency.

3) Oop kiya hai or kyun use kertai hai:

OOP, or Object-Oriented Programming, is a programming paradigm that organizes code around the
concept of objects. Objects are instances of classes, which encapsulate data (attributes) and the
methods (functions) that operate on that data. OOP is used to structure code in a way that promotes
modularity, reusability, and easier maintenance. It helps model real-world entities and their
interactions, making it a powerful approach for creating complex, organized, and maintainable software
systems.

4) static kiya hai:

static keyword in Java is used to create class-level members (variables, methods, and blocks) that
are shared among all instances of a class and can be accessed using the class name rather than
object references.

5) hum kisi method ke sath static laga dai kiya us override ker sektai hai:

you cannot override static methods in the same way you can override instance methods, and the
method called is determined at compile time based on the reference type.

6) Abstract or encapsulation mein difference batayai

Key Difference:

- **Abstract** is about modeling classes based on essential properties and behaviors (what an object
does), often achieved through abstract classes and interfaces.

- **Encapsulation** is about bundling data and methods into a class, hiding internal state, and
controlling access to that state (how an object works), often implemented with private fields and public
methods (getters and setters).
7) Abstraction kyun use kertai hai

In short, we use abstraction in programming to simplify complexity, hide implementation details,


improve code maintainability, enable code reuse, facilitate interoperability, support polymorphism, and
enhance communication and collaboration among developers and stakeholders.

8) Inhertance ka kiya advantage hai

Inheritance in programming offers advantages including code reuse, organization, polymorphism, easier
maintenance, reduced code duplication, better code understanding, specialization, modular
development, consistency, and time savings. It simplifies code and promotes efficient and maintainable
software.

9) aghar mein static method ke sath private laga lu kiya wo inherit hojayai ga: NO

10) Main method ko override ker sektai :

Since the main method is static, it belongs to the class itself rather than instances of the class. In
Java, static methods cannot be overridden because method overriding is a concept that applies
to instance methods, not static methods.

11) main method ko bala overload ker sektai or using method overload example bana ke samjao:

Yes but only the standard public static void main(String[] args) method serves as the entry point
for the Java application. The other overloaded main methods can be called like regular methods
within the class but will not be recognized as entry points by the JVM.

12) int[]arr={1,7,8} and int[] arr2={1,5,7,4,8} inme se wo element nikalo jo in dono array mein na ho

13) == and equals() in dono mein difference kiya hai

To summarize, == compares references for objects and values for primitives, while the equals
method is used to compare the content or state of objects, and it can be customized to provide
specific comparison logic in user-defined classes. When dealing with objects and content-based
comparisons, it's typically more appropriate to use equals rather than ==.

14) String literal or String object mein kiya difference hai

the key difference between string literals and string objects is that string literals are
automatically interned and stored in the string pool for memory optimization, while string
objects explicitly create new instances in the heap memory, regardless of whether identical
strings exist in the string pool. Most of the time, you would use string literals for efficiency and
consistency when working with string constants, rather than creating new string objects.

15) wrapper class kiya hoti hai:

Wrapper classes in Java are used to represent primitive data types as objects. They provide
utility methods for working with these data types, support automatic conversion between
primitives and objects (autoboxing and unboxing), and are essential for using primitive types in
collections that require objects.

16) default method or static method mein kiya difference hai

In short, default methods in Java interfaces provide a default implementation that can be overridden by
implementing classes, whereas static methods in interfaces are associated with the interface itself and
do not require implementations in implementing classes. Default methods are used for backward
compatibility and adding new functionality, while static methods are used for utility functions related to
the interface.

17) Predicat out of below program


class B{
Public static void method(){
System.out.println(“hello”);
}
}
Class B extends A{
Public static void method(){
System.out.println(“Hi”);
}
}
Class Test{
Public static void main(String arg[]){
B b=new B();
b.method();
}
}
Hi will be printed. (Method of B class)
18)What is Servlet:
A servlet is a Java program that extends the capabilities of a web server, allowing it to handle dynamic
web content, process requests, and generate responses. Servlets are commonly used in web
applications to interact with clients and generate dynamic web pages. They follow the Java Servlet API,
which defines the standard interface and lifecycle for these components.
19) How Many ways to create Servlet:
javax.servlet.Servlet interface.
Java class that extends javax.servlet.GenericServlet ,and javax.servlet.http.HttpServlet
20) In tin Servlet mein kon sa better hai Servlet banana ke liye
The best way to create a servlet is by extending `HttpServlet` and using annotations because it's simpler,
more modern, and offers greater flexibility in Java web development.
21) Servlet to Servlet or Servlet to jsp ja sektai hai
Servlet to servlet:
RequestDispatcher dispatcher = request.getRequestDispatcher("/targetServletURL");
dispatcher.forward(request, response);
Servlet to JSP:
RequestDispatcher dispatcher = request.getRequestDispatcher("/yourPage.jsp");
dispatcher.forward(request, response);
Or, you can use response redirection to send the user's browser to a JSP page by setting the
"Location" header with the JSP URL:
response.sendRedirect("/yourPage.jsp");
22) Code likh ke batao ke kese jayai gay Servlet to jsp
23) list bajni ho aghar Servlet se to kese bejay gay
24) life cycle of Servlet
25) What is Hibernate
26) what is advantage of Hibernate
27) life cycle of hibernate
28) hum ek query mysql mein likhtai hai for example ab isko hibernate mein likhni hoto kese likhai gay
29) apache tomcat or wildify mein kiya difference hai
30) Aghar humare pas do application ho ek application dusri application ko data bej rhi ho to hum kitne
server use ker gay
31) hibernate mein one to many ka relation bana ko do
32) Employee or department ki mapping banao
33) Kitne tariko se hibernate ki mapping create ker sektai or unke naam batayai
34) Id or class mein kiya difference hai
35) aghar mere pas tin field hai mujy unme se do mein value pari hai ek mein 10 dusri mein 5 ab mujy in
dono ko plus ker ke tisri mein rakhni hai to kese rakhu ga using javascript or ajax
36) PageContext kiya hai
37) PageConfiguration kiya hai
38) JSTL Tag kiya hai
39) using JSTL loop chalao in JSP
40) aghar mein init method ke ander contructor bana sekta hu
41) aghar mein init ke ander destroy method rekh du kiya program run hojayai ga
42) DataBase kiya hai
43) Left or inner join mein kiya difference hai
44) In or between jo hum database mein use kertai hai in dono mein kiya difference hai
45) aghar do value ke bech wali value print kerwani hoto kese kerwayai gay in mysql
46) Employee or department ke do table banay huwy tha or bol gaya wo data fetch ker ke aao jisko
department assign or kon kon sa assign hai wo fetch kerwao
47) Normalization kiya hai
48) Ek table diya gaya or bola gaya normalization ker ke do
49) one to one ko hum one to many ke relationship bana sektai hai
50) left outer join and right out join ki query likhayi
51) or Jsp mein ajax kese use kere gay or uske oper code likwaya
52) JSon kiya hai
53) JSON kon se form mein data retrieve ker ke deti
54) code likh ke batao jo JSON se data retrieve kere
55) or servlet mein do tin code likwayai wo yad nahi
Or be thay lekin mujy yad nahi abi

You might also like