Skip to main content

#nareshit #interview #questions Interview Questions for freshers 2020/2...


Interview Question Naresh it Hyderabad Campous
=================================================
1.Find the sub string and remove it .if it's not avilable than
return -1;
For example you have a 2 String
Input:
String s1="abc"; String s1="pqr";
String s2="princeabckumar"; String s2="abcdefg";

output=princekumar output=-1;







2. Check the given number is palindrome or not. if given no
is palindrome number than print the digit of the sum given no
if it's not palindrome number than print digit of the product
of the given number.

For example:
input: 2112 input=1234


output=6 output=24




Top 50+ Core Java Interview Questions And Answers
Last Updated:November 12, 2019

Most Frequently asked Java Interview Questions:

In this tutorial, we have covered almost 50+ important core Java interview questions for freshers and experienced candidates.

This post on JAVA Interview Questions is prepared to help you understand the basic concepts of Java programming for interview purposes. All the important JAVA concepts are explained here with examples for your easy understanding.


This tutorial covers JAVA topics like basic Java definitions, Oops concepts, Access specifiers, Collections, Exceptions, Threads, Serialization, etc., with examples to make you get ready perfectly to face any JAVA interview confidently.

Java Interview Questions

Primis Player Placeholder


Most Popular Java Interview Questions
Given below is a comprehensive list of the most important and commonly asked basic and advanced Java programming interview questions with detailed answers.

Q #1) What is JAVA?

Ans: Java is a high-level programming language and is platform-independent.

Java is a collection of objects. It was developed by Sun Microsystems. There are a lot of applications, websites, and games that are developed using Java.

Q #2) What are the features in JAVA?

Ans: Features of Java:

Oops concepts
Object-oriented
Inheritance
Encapsulation
Polymorphism
Abstraction
Platform independent: A single program works on different platforms without any modification.
High Performance: JIT (Just In Time compiler) enables high performance in Java. JIT converts the bytecode into machine language and then JVM starts the execution.
Multi-threaded: A flow of execution is known as a Thread. JVM creates a thread which is called the main thread. The user can create multiple threads by extending the thread class or by implementing the Runnable interface.



Q #3) How does Java enable high performance?

Ans: Java uses Just In Time compiler to enable high performance. JIT is used to convert the instructions into bytecodes.

Q #4) What is the Java IDE’s?

Ans: Eclipse and NetBeans are the IDE's of JAVA.

Q #5) What do you mean by Constructor?

Ans: The points given below explain what a Constructor is in detail:

When a new object is created in a program a constructor gets invoked corresponding to the class.
The constructor is a method that has the same name as class name.
If a user doesn’t create a constructor implicitly a default constructor will be created.
The constructor can be overloaded.
If the user created a constructor with a parameter then he should create another constructor explicitly without a parameter.
Q #6) What is meant by the Local variable and the Instance variable?

Ans: Local variables are defined in the method and scope of the variables that have existed inside the method itself.

An instance variable is defined inside the class and outside the method and scope of the variables exist throughout the class.

Q #7) What is a Class?

Ans: All Java codes are defined in a class. A-Class has variables and methods.

Variables are attributes that define the state of a class.

Methods are the place where the exact business logic has to be done. It contains a set of statements (or) instructions to satisfy the particular requirement.

Example:

public class Addition{ //Class name declaration
int a = 5; //Variable declaration
int b= 5;
public void add(){ //Method declaration
int c = a+b;
}
}
Q #8) What is an Object?

Ans: An instance of a class is called an object. The object has state and behavior.

Whenever the JVM reads the “new()” keyword then it will create an instance of that class.

Example:

public class Addition{
public static void main(String[] args){
Addion add = new Addition();//Object creation
}
}
The above code creates the object for the Addition class.

Q #9)What are the Oops concepts?

Ans: Oops concepts include:

Inheritance
Encapsulation
Polymorphism
Abstraction
Interface
Q #10) What is Inheritance?

Ans: Inheritance means one class can extend to another class. So that the codes can be reused from one class to another class.

The existing class is known as Superclass whereas the derived class is known as a subclass.

Example:

Superclass:
public class Manipulation(){
}
Subclass:
public class Addition extends Manipulation(){
}
Inheritance is applicable for public and protected members only. Private members can’t be inherited.

Q #11) What is Encapsulation?

Ans: Purpose of Encapsulation:

Protects the code from others.
Code maintainability.
Example:

We are declaring ‘a' as an integer variable and it should not be negative.

public class Addition(){
int a=5;
}
If someone changes the exact variable as “a = -5” then it is bad.

In order to overcome the problem we need to follow the below steps:

We can make the variable as private or protected one.
Use public accessor methods such as set and get.
So that the above code can be modified as:

public class Addition(){
private int a = 5; //Here the variable is marked as private
}
The below code shows the getter and setter.

Conditions can be provided while setting the variable.

get A(){
}
set A(int a){
if(a>0){// Here condition is applied
.........
}
}
For encapsulation, we need to make all the instance variables as private and create setter and getter for those variables. Which in turn will force others to call the setters rather than access the data directly?

Q #12) What is Polymorphism?

Ans: Polymorphism means many forms.

A single object can refer to the superclass or subclass depending on the reference type which is called polymorphism.

Example:

Public class Manipulation(){ //Super class
public void add(){
}
}
public class Addition extends Manipulation(){ // Sub class
public void add(){
}
public static void main(String args[]){
Manipulation addition = new Addition();//Manipulation is reference type and Addition is reference type
addition.add();
}
}
Using Manipulation reference type we can call the Addition class “add()” method. This ability is known as Polymorphism.

Polymorphism is applicable for overriding and not for overloading.

Q #13) What is meant by Method Overriding?

Ans: Method overriding happens if the subclass method satisfies the below conditions with the Superclass method:

Method name should be the same
The argument should be the same
Return type also should be the same




Comments

Popular posts from this blog

How to Send OTP in Mobile Number | login with OTP mobile Number | How to send OTP in mobile no with Spring Boot APP

   ðŸ˜‚               Login with Mobile Number OTP ---------------------------------------------------------------------------- If you want to develop a project to log in with OTP mobile Number in Spring Boot Applications then this post for you. In this post, I am going to use some other service to send the OTP in mobile number. we have to use it in this project spring boot. we are going to use Twilio to send SMS. we are going to use a web socket to send the data from the browser to the SMS gateway. Oracle Database for store the user details. <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> <version>2.3.3.RELEASE</version> </dependency> <dependency> <groupId>com.twilio.sdk</grou

Spring Boot With MySQL Database connection with Examples | MySQl Database Configuration with Spring Boot Projects

 ðŸ˜ƒ MySQL Database Configuration with Spring Boot Projects  In this article, we are going to introduce How to connect MySQL Database with the Spring Boot project. pom.xml   <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <scope>runtime</scope> <optional>true</optional> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>org.projectlombok</gro

How can we create Auto generated field or ID for mongodb using spring boot

😂 How can we create an Auto-generated field or ID for MongoDB using spring boot? First Create One Application Like Mongodb_sequence-id-generator Pom.XML <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-mongodb</artifactId> </dependency> <dependency> <groupId>de.flapdoodle.embed</groupId> <artifactId>de.flapdoodle.embed.mongo</artifactId> </dependency> User.java package com.app; import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Transient; import org.springframework.data.mongodb.core.mapping.Document; @Document(collection = "users_db") public class User { @Transient public static final String SEQUENCE_NAME = &