Search This Blog

Showing posts with label Java Developer. Show all posts
Showing posts with label Java Developer. Show all posts

Sunday, October 15, 2023

Most Important Core Java Interview Questions Answers

 1.) What is serialization?

Quite simply, object serialization provides a program the ability to read or write a whole object to and from a raw byte stream. It allows Java objects and primitives to be encoded into a byte stream suitable for streaming to some type of network or to a file system, or more generally, to a transmission medium or storage facility. A serializable object must implement the Serializable interface. We use Object Output Stream to write this object to a stream and Object Input Stream to read it from the stream.


2.) Is synchronized a modifier? identifier?? what is it??

It's a modifier. Synchronized methods are methods that are used to control access to an object. A thread only executes a synchronized method after it has acquired the lock for the method's object or class. Synchronized statements are similar to synchronized methods. A synchronized statement can only be executed after a thread has acquired the lock for the object or class referenced in the synchronized statement.


3.) What is a singleton class? where is it used?

Singleton is a design pattern meant to provide one and only one instance of an object. Other objects can get a reference to this instance through a static method (class constructor is kept private). Why do we need one? Sometimes it is necessary, and often sufficient, to create a single instance of a given class. This has advantages in memory management, and for Java, in garbage collection. Moreover, restricting the number of instances may be necessary or desirable for technological or business reasons--for example, we may only want a single instance of a pool of database connections.


4.) Why java does not have multiple inheritance?

The Java design team strove to make Java:

• Simple, object-oriented, and familiar

• Robust and secure

• Architecture neutral and portable

• High performance

• Interpreted, threaded, and dynamic


The reasons for omitting multiple inheritance from the Java language mostly stem from the "simple, object-oriented, and familiar" goal. As a simple language, Java's creators wanted a language that most developers could grasp without extensive training. To that end, they worked to make the language as similar to C++ as possible (familiar) without carrying over C++'s unnecessary complexity (simple).

In the designers' opinion, multiple inheritance causes more problems and confusion than it solves. So they cut multiple inheritance from the language (just as they cut operator overloading). The designers' extensive C++ experience taught them that multiple inheritance just wasn't worth the headache.


5.)Why java is not 100% oops?

Many people say this because Java uses primitive types such as int, char, double. But then all the rest are objects. Confusing question.


6.) What is a resource bundle?

In its simplest form, a resource bundle is represented by a text file containing keys and the text value for each key.


7.) What is a transient variable?

The transient variables can't be serialized. For example, if a variable is declared as transient in a Serializable class and the class is written to an Object Stream, the value of the variable can't be written to the stream instead when the class is retrieved from the Object Stream the value of the variable becomes null.


Saturday, July 10, 2021

What are Packages in core java and how to use them ?

  Java package is a technique for organizing Java classes into namespaces similar to the modules of Modula, providing modular programming in JavaJava packages can be stored in compressed files called JAR files, allowing classes to be downloaded faster as groups rather than individually.

Packages are used in Java in order to prevent naming conflicts, to control access, to make searching/locating and usage of classes, interfaces, enumerations and annotations easier, etc.

A Package can be defined as a grouping of related types(classes, interfaces, enumerations and annotations ) providing access protection and namespace management.

Some of the existing packages in Java are::

·        java. lang - bundles the fundamental classes

·        java.io - classes for input, output functions are bundled in this package

Programmers can define their own packages to bundle groups of classes/interfaces, etc. It is a good practice to group related classes implemented by you so that a programmer can easily determine that the classes, interfaces, enumerations, annotations are related.

Since the package creates a new namespace there won't be any name conflicts with names in other packages. Using packages, it is easier to provide access control and it is also easier to locate the related classes.

Creating a package:


When creating a package, you should choose a name for the package and put a package statement with that name at the top of every source file that contains the classes, interfaces, enumerations, and annotation types that you want to include in the package.

The package statement should be the first line in the source file. There can be only one package statement in each source file, and it applies to all types in the file.

If a package statement is not used then the class, interfaces, enumerations, and annotation types will be put into an unnamed package.

 

What are Packages in java and how to use them?

 OOPS CONCEPT

Packages in Java are a mechanism to encapsulate a group of classes, interfaces, and sub-packages. Many implementations of Java use a hierarchical file system to manage source and class files. It is easy to organize class files into packages. All we need to do is put related class files in the same directory, give the directory a name that relates to the purpose of the classes, and add a line to the top of each class file that declares the package name, which is the same as the directory name where they reside.

In java, there are already many predefined packages that we use while programming.

For example: java.langjava.iojava.util etc.


However one of the most useful features of java is that we can define our own packages


Advantages of using a package:


Before discussing how to use them Let see why we should use packages.

§  Reusability:  Reusability of code is one of the most important requirements in the software industry. Reusability saves time, effort and also ensures consistency. A class once developed can be reused by any number of programs wishing to incorporate the class in that particular program.

§  Easy to locate the files.

§  In a real-life situation, there may arise scenarios where we need to define files of the same name. This may lead to “name-space collisions”. Packages are a way of avoiding “name-space collisions”.


Types of packages:


1) User-defined package: The package we create is called a user-defined package.
2) Built-in package: The already defined package like java.io.*, java.lang.* etc are known as built-in packages.


Defining a Package:


This statement should be used at the beginning of the program to include that program in that particular package.


package  <package name>;

 

Tuesday, June 22, 2021

Roadmap of Full Stack Java Developer

Get started with the Full Stack Java Developer and explore everything about the full stack java developer.

There are a whole lot of technologies to learn and not all of them can be java based. At the very least, you will have to learn There are a whole lot of technologies to learn, and not all of it can be java based. At the very least, you will have to learn full-stack java development every beginner learns Core Java, Spring, Hibernate, Spring Boot, Microservices, SQL.

Becoming a full-stack developer seems an intimidating task, especially if you are completely new to the field of coding. As a beginner, you might think that you have a whole lot to learn within a short span of time. The languages, frameworks, libraries, and databases along with everything else required.

Phase-1: Implement OOPS using JAVA with Data Structures and Beyond

Brush up on your knowledge of software development fundamentals, Agile and Scrum methodologies, Java and data structures, GIT to manage version control systems, and Maven to manage project dependencies.

Phase-2: Become a back-end expert

Familiarize yourself with the back-end technologies by implementing knowledge of SQL, Java Servlets, and relational database ORM with Hibernate. Learn to connect databases with JDBC and work with RESTful web services.

Phase-3: Implement Frameworks the DevOps way

Master UI skills with advanced HTML and CSS and build 3-tier applications with Spring framework, Angular, JUnit5, SOAP. This phase will enable you to deploy continuous integration and automation using a common DevOps tool: Jenkins.

Phase-4: Develop a Web Application using frontend stack

Build real-world websites and applications using the front-end stack technologies such as HTML, CSS, JavaScript, and Angular. Handle diverse data types and manage your applications efficiently using MongoDB.

Phase-5: Testing in a DevOps Lifecycle

Begin automation testing and integration with Selenium Webdriver. Create seamless development and production environments using containerization with Docker and manage applications on Amazon S3 servers.

Full Stack Java Developer Capstone project provides you with hands-on working experience, the objective being to develop the entire application from scratch and deploy it into a pseudo-production environment.

Advantages:-

The advantage of being a full-stack developer is:

You can master all the techniques involved in a development project.

You can make a prototype very rapidly.

You can provide help to all the team members.

You can reduce the cost of the project.

You can reduce the time used for team communication.

You can switch between front and back-end development based on requirements.

You can better understand all aspects of new and upcoming technologies.