Java Programming Basics
This Java course covers the length and breadth of this platform-independent and object-oriented language.Preview Java Programming Basics course
View Course Curriculum Price Match Guarantee Full Lifetime Access Access on any Device Technical Support Secure Checkout   Course Completion Certificate- 71% Started a new career
BUY THIS COURSE (
USD 17 USD 41 ) - 85% Got a pay increase and promotion
Students also bought -
- JavaScript Programming
- 35 hours
- USD 17
- 518 Learners
- Career Path - IT Consultant
- 200 Hours
- USD 45
- 5851 Learners
- Bundle Course - Java (Core Java - JSP - Java Servlets)
- 50 Hours
- USD 27
- 4202 Learners
Java is one of the most used and most popular programming languages in the world of IT development. Given its properties of platform independence, object-oriented approach, reusable code and dynamic classes, Java has emerged to be the most preferred language for programmers. It is quite easy to learn and implement, thus making it highly favorable in the programming community. Its popularity also stems from the fact that it was built keeping security in mind, and enables programmers to write code with fewer bugs, in lesser time.
Besides the fact that Java is among the top programming languages of 2020 and perhaps will remain so for at least a decade, Java has nailed it in almost every domain you can think of! As Java is secure and multi-threaded, it is perfect for Banking and transaction management services. E-commerce shops and billing software have their logic written in frameworks based on Core Java. Mobile OS like Android uses Java APIs. Stock market algorithms are based out of Java. Java along with other frameworks like Spring makes for a robust combination to sort implementation dependencies and write server-side applications in Finance and IT domains.
Java is fast, reliable and secure. From desktop to web applications, scientific supercomputers to gaming consoles, cell phones to the Internet, Java is used in every nook and corner. Java is a very successful language and it has gained huge popularity.
Key features of Java include:
1) Java is a simple language - Java is easy to learn and its syntax is clear and concise. It is based on C++ (so it is easier for programmers who know C++).
2) Java is a platform-independent language - The programs written in Java language, after compilation, are converted into an intermediate level language called the bytecode which is a part of the Java platform irrespective of the machine on which the programs run.
3) Java is an object-oriented programming language - OOP makes the complete program simpler by dividing it into a number of objects. The objects can be used as a bridge to have data flow from one function to another.
4) Java is a robust language - Java programs must be reliable because they are used in both consumer and mission-critical applications, ranging from Blu-ray players to navigation systems.
5) Java is a multithreaded language - Java can perform many tasks at once by defining multiple threads.
6) Java programs can create applets - Applets are programs that run in web browsers.
7) Java does not require any preprocessor - It does not require inclusion of header files for creating a Java application.
The Java Fundamentals course from Uplatz teaches handy skills in Java programming language to professionals who have little or no experience in programming. This Java course covers the length and breadth of this platform-independent and object-oriented language that you can learn and implement easily for programming purposes.
Course/Topic - Java Programming - all lectures
-
In this video you will learn the introduction to Java programming. This tutorial explains the installation and usage of the Java programming language. It also contains examples for standard programming tasks.
-
In this video you will learn based on the data type of a variable, the operating system allocates memory and decides what can be stored in the reserved memory. Therefore, by assigning different data types to variables, you can store integers, decimals, or characters in these variables.
-
In this video you will learn about the control statement in java is a statement that determines whether the other statements will be executed or not. It controls the flow of a program. An 'if' statement in java determines the sequence of execution between a set of two statements.
-
In this video you will learn Looping in programming languages is a feature which facilitates the execution of a set of instructions/functions repeatedly while some condition evaluates to true. while loop: A while loop is a control flow statement that allows code to be executed repeatedly based on a given Boolean condition.
-
In this video you learn about Classes and Objects are basic concepts of Object Oriented Programming which revolve around the real life entities. A class is a user defined blueprint or prototype from which objects are created. It represents the set of properties or methods that are common to all objects of one type.
-
In this you will learn In Java, static keyword is mainly used for memory management. It can be used with variables, methods, blocks and nested classes. It is a keyword which is used to share the same variable or method of a given class. Basically, static is used for a constant variable or a method that is same for every instance of a class.
-
In this video you will learn about Array an array is a group of like-typed variables that are referred to by a common name. Arrays in Java work differently than they do in C/C++. Following are some important points about Java arrays.
-
In this video you will learn the java.util.Arrays.binarySearch(Object[] a, Object key) method searches the specified array for the specified object using the binary search algorithm. The array be sorted into ascending order according to the natural ordering of its elements prior to making this call. If it is not sorted, the results are undefined.
-
In this video, you will learn about the Java multidimensional array using 2-dimensional arrays and 3-dimensional arrays with the help of examples.
-
In this video you will learn the java.util.Arrays.sort(Object[] a, int fromIndex, int toIndex) method sorts the specified range of the specified array of objects into ascending order, according to the natural ordering of its elements. The range to be sorted extends from index fromIndex, inclusive, to index toIndex, exclusive.
-
In this video you will learn Inheritance in Java is a mechanism in which one object acquires all the properties and behaviors of a parent object. It is an important part of OOPs (Object Oriented programming system).
-
In this video you will learn more about Inheritance.
-
In this video you will learn In Java, two or more methods can have same name if they differ in parameters (different number of parameters, different types of parameters, or both). These methods are called overloaded methods and this feature is called method overloading.
-
In the last video, you will learn about inheritance. Inheritance is an OOP property that allows us to derive a new class (subclass) from an existing class (superclass). The subclass inherits the attributes and methods of the superclass.
-
In this video you will learn about t he super keyword in java is a reference variable that is used to refer parent class objects. ... Basically this form of super is used to initialize superclass variables when there is no constructor present in superclass. On the other hand, it is generally used to access the specific variable of a superclass.
-
In this video you will learn about the Java programming language, the final keyword is used in several contexts to define an entity that can only be assigned once. Once a final variable has been assigned, it always contains the same value.
-
In this video you will learn about Polymorphism, it is the ability of an object to take on many forms. The most common use of polymorphism in OOP occurs when a parent class reference is used to refer to a child class object. Any Java object that can pass more than one IS-A test is considered to be polymorphic.
-
In this video you will learn about the class which is declared with the abstract keyword is known as an abstract class in Java. It can have abstract and non-abstract methods (method with the body).
-
In this video you will learn about methods form the object's interface with the outside world; the buttons on the front of your television set, for example, are the interface between you and the electrical wiring on the other side of its plastic casing. You press the "power" button to turn the television on and off.
-
In this video you will learn the interface is a reference type in Java. It is similar to class. It is a collection of abstract methods. A class implements an interface, thereby inheriting the abstract methods of the interface.
-
In this video you will learn about the interface in Java is a mechanism to achieve abstraction. There can be only abstract methods in the Java interface, not method body. It is used to achieve abstraction and multiple inheritance in Java.
-
In this video you will learn about the main difference is methods of a Java interface are implicitly abstract and cannot have implementations. A Java abstract class can have instance methods that implements a default behavior. ... A Java class can implement multiple interfaces but it can extend only one abstract class.
-
In this video you will learn about the packages in Java is used to group related classes. Think of it as a folder in a file directory. We use packages to avoid name conflicts, and to write a better maintainable code. Built-in Packages (packages from the Java API) User-defined Packages (create your own packages)
-
In this video you will learn about the access modifier, there are four types of Java access modifiers: Private: The access level of a private modifier is only within the class. Default: The access level of a default modifier is only within the package. Protected: The access level of a protected modifier is within the package and outside the package through child class.
-
In this video you will learn about the Encapsulation in Java is a mechanism of wrapping the data (variables) and code acting on the data (methods) together as a single unit. In encapsulation, the variables of a class will be hidden from other classes, and can be accessed only through the methods of their current class.
-
In this video you will learn about the Strings in Java are Objects that are backed internally by a char array. Since arrays are immutable (cannot grow), Strings are immutable as well. Whenever a change to a String is made, an entirely new String is created. Below is the basic syntax for declaring a string in Java programming language.
-
In this video you will learn about Java String, how to create it and its various methods with the help of examples. In Java, a string is a sequence of characters. For example, "hello" is a string containing a sequence of characters 'h', 'e', 'l', 'l', and 'o'.
-
In this video you will learn about the Exception (or exceptional event) is a problem that arises during the execution of a program. When an Exception occurs the normal flow of the program is disrupted and the program/Application terminates abnormally, which is not recommended, therefore, these exceptions are to be handled.
-
In this video you will learn about the Customized Exception Handling: Java exception handling is managed via five keywords: try, catch, throw, throws, and finally. Briefly, here is how they work. Program statements that you think can raise exceptions are contained within a try block. If an exception occurs within the try block, it is thrown.
-
In this video you will learn about the Finally block contains all the crucial statements that must be executed whether exception occurs or not. ... The statements present in this block will always execute regardless of whether exception occurs in try block or not such as closing a connection, stream etc.
-
In this video you will learn about the Java exception this fall into two main categories: checked exceptions and unchecked exceptions. In this article, we'll provide some code samples on how to use them.
-
In this video you will learn about the Throw is a keyword which is used to throw an exception explicitly in the program inside a function or inside a block of code. Throws is a keyword used in the method signature used to declare an exception which might get thrown by the function while executing the code
-
In this video you will learn how to create a custom exception in Java. We’ll show how user-defined exceptions are implemented and used for both checked and unchecked exceptions.
-
In this video you will learn about the Threads which allows a program to operate more efficiently by doing multiple things at the same time. Threads can be used to perform complicated tasks in the background without interrupting the main program.
-
In this video you will learn about the Thread class provides the join, method which allows one thread to wait until another thread completes its execution. If t is a Thread object whose thread is currently executing, then t. join, will make sure that t is terminated before the next instruction is executed by the program.
-
In this video you will learn about the Synchronization in java is the capability to control the access of multiple threads to any shared resource. Java Synchronization is better option where we want to allow only one thread to access the shared resource.
-
In this video you will learn about the Inter Thread Communication, if you are aware of inter-process communication then it will be easy for you to understand interthread communication. Interthread communication is important when you develop an application where two or more threads exchange some information.
-
In this video you will learn about the Linked List, it is a part of the Collection framework present in java. util package. This class is an implementation of the Linked List data structure which is a linear data structure where the elements are not stored in contiguous locations and every element is a separate object with a data part and address part.
-
In this video you will learn about the Linked List, it is a part of the Collection framework present in java. util package. This class is an implementation of the LinkedList data structure which is a linear data structure where the elements are not stored in contiguous locations and every element is a separate object with a data part and address part.
-
In this video you will learn about the Java Hash Set it class is used to create a collection that uses a hash table for storage. It inherits the Abstract Set class and implements Set interface. The important points about Java HashSet class are: HashSet stores the elements by using a mechanism called hashing. HashSet contains unique elements only.
-
In this video you will learn about the Comparable and comparator, these both are an interface that can be used to sort the elements of the collection. Comparator interface belongs to java.util package while comparable belongs to java. Lang package. Comparator interface sort collection using two objects provided to it, whereas comparable interface compares" this" refers to the one objects provided to it.
-
In this video you will learn about the queue its interface is provided in java. util package and it implements the Collection interface. The queue implements FIFO i.e. First in First Out. This means that the elements entered first are the ones that are deleted first.
-
In this video you will learn about the Map its interface present in java util package represents a mapping between a key and a value. The Map interface is not a subtype of the Collection interface. Therefore, it behaves a bit differently from the rest of the collection types. A map contains unique keys.
-
In this video you will learn about the Map its implementations are grouped into general-purpose, special-purpose, and concurrent implementations.
-
In this video you will learn about JDBC it stands for Java Database Connectivity. JDBC is a Java API to connect and execute the query with the database. It is a part of JavaSE (Java Standard Edition). JDBC API uses JDBC drivers to connect with the database. There are four types of JDBC drivers.
-
In this video you will learn about the JDBC API is a Java API that can access any kind of tabular data, especially data stored in a Relational Database. JDBC works with Java on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX.
-
In this video you will learn how to create a simple JDBC application. This will show you how to open a database connection, execute a SQL query, and display the results.
-
In this video you will learn how to use a Java JDBC Prepared Statement instead of a Statement and benefit from the features of the Prepared Statement. The Java JDBC Prepared Statement primary features are: Easy to insert parameters into the SQL statement
-
In this video you will learn about Callable Statement Database in this Once a connection is obtained, we can interact with the database. The JDBC Statement, Callable Statement, and Prepared Statement interfaces define the methods and properties that enable you to send SQL or PL/SQL commands and receive data from your database
-
In this video you will learn about the dynamic database refers to the process of firing SQL queries on demand to create the schema afresh. The JDBC API library is quite capable of dealing with the situation.
-
In this video you will learn about the Lambda expressions are introduced in Java 8 and are touted to be the biggest feature of Java 8. Lambda expression facilitates functional programming, and simplifies the development a lot.
-
In this video you will learn about the Predicate it is a generic functional interface that represents a single argument function that returns a Boolean value (true or false). This interface available in java unit function package and contains a test method that evaluates the predicate of a given argument.
-
In this video you will learn about the article Lambda Expression with Collections are discussed with examples of sorting different collections like Array List, Tree Set, Tree Map, etc.
-
In this video you will learn about the Consumer it is an in-built functional interface introduced in Java 8 in the java. util. function package. Consumer can be used in all contexts where an object needs to be consumed that is taken as input, and some operation is to be performed on the object without returning any result.
-
In this video you will learn about the Stream, it is a new abstract layer introduced in Java 8. Using stream, you can process data in a declarative way similar to SQL statements. For example, consider the following SQL statement.
-
In this video, you will learn the major pieces of new functionality Java 8 had added – Streams. We'll explain what streams are about and showcase the creation and basic stream operations with simple examples
• Examine the Java development environment
• Identify fundamentals of Java syntax
• Describe how to compile and run a simple Java application
• Describe how to construct simple variables and arrays
• Describe how to construct simple expressions and control flow
• Identify object-oriented programming concepts
• Describe how Java implements object-oriented programming
• Describe the structure of classes
• Describe how simple inheritance is used
• Describe class and variable access modifiers
Java Overview
a) How the Java Environment Works
b) HelloWorld Program
c) Launch Single-File Source Code
d) jShell REPL
e) Comments and Terminators
f) Identifiers
Syntax and Types
a) Java Variables
b) var declarations
c) Java Types
d) Basic Java Types
e) Reference types
f) Conditional Expressions
g) Logical operators
h) If statement
i) While Statement
j) Do Statement
k) For statement
l) Special flow of control operators
m) Switch statement
n) Numerical Operators
o) Casting
p) Strings
Classes and Objects
a) What is an Object?
b) Objects and Encapsulation
c) What is a Class?
d) Class Object Relationship
e) The Person class
f) Variable types
g) Constructors
h) Working with the class Person
Working with Methods
a) Method Definitions
b) Method Arguments & Return Types
c) Overloading Methods
d) Method Invocations
e) Defining methods
f) Constructors Versus Methods
g) toString() method
h) Adding behaviour to the class Person
i) The PersonApp program
Class Inheritance
a) Inheritance in Java
b) Implementing Inheritance
c) Rule for overriding methods
d) Rules for Polymorphic variables
e) Casting and Inheritance
f) The super variable
g) Constructors and Inheritance
Abstract Classes, Class Side Behaviour and Final
a) Abstract Classes
b) Abstract Classes in Java
c) Defining an Abstract Class
d) Extending an Abstract Class
e) Using Concrete Subclasses
f) Class Side Information
g) Class Side Data
h) Class Side Behaviour
i) Final Keyword
Java Interfaces and Enumerations
a) What is an Interface in Java?
b) Basic Interface Definitions
c) Implementing an Interface
d) Interface
e) Using an Interface in a Contract
f) Inheritance by Interfaces and Types
g) Classes and multiple Interfaces
h) Default Interface Methods
i) Static Interface Methods
j) Enumeration Support
k) Implementing Enumerated Types
Packages
a) Packages
b) Class-Package Relationship
c) Declaring Packages
d) Packaging the Person class
e) Role of the Classpath
f) JAR Files
g) Encapsulation and Packages
h) Class modifier
i) Constructor Modifier
j) Variable Modifier
k) Method Modifiers
l) Package Summary
Java 9+ Modules
a) Introduction the JPMS
b) Java Platform Module System
c) Why we need modules
d) Look at what modules are
e) How to define a module
f) How to create a single module application
g) How to link modules
Arrays
a) What is a Java Array?
b) Creating arrays of Objects
c) Accessing Array Elements
d) Main method args array
e) Shorthand form
f) Ragged Arrays in Java
g) Working with Ragged Arrays
h) Implications of Inheritance for Arrays
i) Integer Array Example
Java Generics
a) Generics and Basic Types
b) Generics and Their Types
c) Adding Generics to your classes
d) A simple user-defined Generic class (the Bag class)
e) Type Equality
f) Generic Collection Assignment
g) Generics and Inheritance
Collections Classes
a) Collections API
b) ArrayList
c) Interfaces vs. Concrete Classes
d) HashMap
e) Iteration and Enumeration
f) Queues
g) Generics and Collections
h) For Loops
i) Boxing and Unboxing
j) Raw Collections
Java 9+ Immutable Collections
a) Why Immutability?
b) Immutability
c) List.of Factory method
d) Set.of Factory method
e) Map.of Factory method
f) Immutable Collection Nodes
g) Java 10 Enhancement
Error and Exception Handling
a) Errors & Exceptions
b) Exception types in Java
c) Part of the Exception Hierarchy
d) Exception Handling
e) Local Handling
f) Exception Handling Example
g) Passing the Buck
h) Try with Resources
i) Defining new Exceptions
j) Chained Exceptions
Nested / Inner Classes
a) Four types of Nested / Inner Class
b) Properties of Member level inner classes
c) Properties of Method Inner classes
d) Anonymous Method Inner classes
e) Java 11 Nest-based Access
Java Functions
a) Functional Programming
b) Functional Programming in Java
c) Functional Interfaces
d) Using Functional Interfaces
e) Lambdas in Java
f) Closing / Capturing Variables
g) Returning Functions
h) Combining Functions
i) Higher-Order Functions
j) Defining Lambdas
i) Method References
Java Optional Type
a) Null considered Harmful
b) Java Optional Type
c) Optional Variables
d) Creating Optional values
e) Method Summary
Java 9 Streams
a) Streams
b) Streams from Collections
c) Terminal / Non Terminal Operators
d) Creating a Stream
e) Map Operation
f) Collectors
g) Filter operation
h) Sorted operation
i) ForEach
j) Pipelining Operations
k) Parallel Streams
l) Not just collections
Files, Paths and IO Streams
a) Introducing NIO.2
b) Paths class and Path Interface
c) The Files class
d) File Attributes
e) The File Watcher Service
f) IO Streams
g) Scanners
By the end of this course, you will have:
a) Learnt about Java class and Objects
b) Explored defining methods and properties
c) Examined Class Inheritance
d) Understood Java Interfaces and Enumerations
e) Considered how to use Packages and Modules
f) Learnt about Functional Programming in Java
g) Understood how to handle Errors and Exceptions
h) Worked with Files, paths and Stream IO
i) Used the new Streams API for processing data
j) Explored the Collection classes
This Java Programming Basics training course will help the participant to master the Java Programming language. As a part of this Java Programming Basics training, the participants will master the Java programming language.
In Java Programming Basics Course module, the participants understand that Java programming language is used to improve the coding quality. In the Java Programming Basics course, the participants will learn to deal with object-oriented approach, dynamic class, reusable code.
The Java Developer get trained in writing code with less bugs. Java Programming Basics tutorial helps the participants to fulfil the role of a Java Developer. Java Programming Basics training course requires none of any prerequisite.
Java Programming Basics is a language that an emerging developer need to know well. The Java Programming Basics training course from Uplatz can help the participants to understand the java coding is applied in billing software, e-commerce shops, banking and other transaction services. The Java Programming Basics training course validates whether the participants has proven basic knowledge of java programming language. The Java Programming Basics training course helps the participants to create and maintain applications, software and other management services.
Uplatz online training ensures the participants to successfully go through the Java Programming Basics training course. Uplatz provides appropriate teaching and expertise training is provided to equip the participants for implementing the learnt concepts in an enterprise.
Course Completion Certificate will be awarded by Uplatz upon the completion of the Java programming basics course training.
The Java Developer draws an average salary of $104,264 per year depending on the knowledge and hands-on experience. The Java Developer job roles are in high demand and make a promising career.
The Java Developers have huge demand across various MNC’s. The importance of Java and object-oriented technology in various companies can open up good job opportunities. The leading companies hire Java Developer considering their skill of mastering Java programming and create application or software. The Participants earn Java Programming Basics training through our course completion certificate.
The Java Programming Basics course is ideally designed for programmers and those who aspire to build their career in Java programming.
After pursuing Java Programming Basics course the participants can pursue a wide range of career paths.
The following are the job titles:
· Java Programmer/Developer
· Software Developer
· Application Developer
· Software Programmer
Java Programming Basics Training course is worth for any Java or other developers to improve their programming skills.
Q #1) What is JAVA?
Answer: 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?
Answer: Features of Java are as follows:
· 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?
Answer: Java uses Just In Time compiler to enable high performance. It is used to convert the instructions into bytecodes.
Q #4) Name the Java IDEs?
Answer: Eclipse and NetBeans are the IDEs of JAVA.
Q #5) What do you mean by Constructor?
Answer: Constructor can be explained in detail with enlisted points:
- When a new object is created in a program a constructor gets invoked corresponding to the class.
- The constructor is a method which has the same name as the 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?
Answer:
Local variables are defined in the method and scope of the variables existed inside the method itself.
Instance variable is defined inside the class and outside the method and the scope of the variables exists throughout the class.
Q #7) What is a Class?
Answer: All Java codes are defined in a Class. It has variables and methods.
Variables are attributes which 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?
Answer: 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?
Answer: OOPs concepts include:
- Inheritance
- Encapsulation
- Polymorphism
- Abstraction
- Interface
Q #10) What is Inheritance?
Answer: 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 the Super class whereas the derived class is known as a sub class.
Example:
Super class: public class Manupulation(){ } Sub class: 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?
Answer: 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?
Answer: Polymorphism means many forms.
A single object can refer to the super-class or sub-class 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?
Answer: Method overriding happens if the sub-class method satisfies the below conditions with the Super-class method:
- Method name should be the same
- The argument should be the same
- Return type also should be the same
The key benefit of overriding is that the Sub-class can provide some specific information about that sub-class type than the super-class.
Example:
public class Manipulation{ //Super class public void add(){ ……………… } }
Public class Addition extends Manipulation(){ Public void add(){ ……….. } Public static void main(String args[]){ Manipulation addition = new Addition(); //Polimorphism is applied addition.add(); // It calls the Sub class add() method } } |
addition.add() method calls the add() method in the Sub-class and not the parent class. So it overrides the Super-class method and is known as Method Overriding.
Q #14) What is meant by Overloading?
Answer: Method overloading happens for different classes or within the same class.
For method overloading, sub-class method should satisfy the below conditions with the Super-class method (or) methods in the same class itself:
- Same method name
- Different argument type
- May have different return types
Example:
public class Manipulation{ //Super class public void add(String name){ //String parameter ……………… } }
Public class Addition extends Manipulation(){ Public void add(){//No Parameter ……….. } Public void add(int a){ //integer parameter
} Public static void main(String args[]){ Addition addition = new Addition(); addition.add(); } } |
Here the add() method has different parameters in the Addition class is overloaded in the same class as well as with the super-class.
Note: Polymorphism is not applicable for method overloading.
Q #15) What is meant by Interface?
Answer: Multiple inheritances cannot be achieved in java. To overcome this problem Interface concept is introduced.
An interface is a template which has only method declarations and not the method implementation.
Example:
Public abstract interface IManupulation{ //Interface declaration Public abstract void add();//method declaration public abstract void subtract(); } |
- All the methods in the interface are internally public abstract void.
- All the variables in the interface are internally public static final that is constants.
- Classes can implement the interface and not extends.
- The class which implements the interface should provide an implementation for all the methods declared in the interface.
public class Manupulation implements IManupulation{ //Manupulation class uses the interface Public void add(){ …………… } Public void subtract(){ ……………. } }
|
Q #16) What is meant by Abstract class?
Answer: We can create the Abstract class by using the “Abstract” keyword before the class name. An abstract class can have both “Abstract” methods and “Non-abstract” methods that are a concrete class.
Abstract method:
The method which has only the declaration and not the implementation is called the abstract method and it has the keyword called “abstract”. Declarations are the ends with a semicolon.
Example:
public abstract class Manupulation{ public abstract void add();//Abstract method declaration Public void subtract(){ } } |
- An abstract class may have a non- abstract method also.
- The concrete Subclass which extends the Abstract class should provide the implementation for abstract methods.
Q #17) Difference between Array and Array List.
Answer: The Difference between Array and Array List can be understood from the below table:
Array
Array List
Size should be given at the time of array declaration. |
Size may not be required. It changes the size dynamically. |
To put an object into array we need to specify the index. |
No index required. |
Array is not type parameterized |
ArrayList in java 5.0 are parameterized. |
Q #18) Difference between String, String Builder, and String Buffer.
Answer:
String: String variables are stored in a “constant string pool”. Once the string reference changes the old value that exists in the “constant string pool”, it cannot be erased.
Example:
String name = “book”;
Constant string pool
If the name-value has changed from “book” to “pen”.
Constant string pool
Then the older value retains in the constant string pool.
String Buffer:
- Here string values are stored in a stack. If the values are changed then the new value replaces the older value.
- The string buffer is synchronized which is thread-safe.
- Performance is slower than the String Builder.
Example:
String Buffer name =”book”;
Once the name value has been changed to “pen” then the “book” is erased in the stack.
String Builder:
This is the same as String Buffer except for the String Builder which is not threaded safety that is not synchronized. So obviously performance is fast.
Q #19) Explain about Public and Private access specifiers.
Answer: Methods and instance variables are known as members.
Public:
Public members are visible in the same package as well as the outside package that is for other packages.
Public members in Class A are visible to Class B (same package) as well as Class C (different packages).
Private:
Private members are visible in the same class only and not for the other classes in the same package as well as classes in the outside packages.
Private members in class A are visible only in that class. It is invisible for class B as well as class C.
Q #20) Difference between Default and Protected access specifiers.
Answer:
Default: Methods and variables declared in a class without any access specifiers are called default.
Default members in Class A are visible to the other classes which are inside the package and invisible to the classes which are outside the package.
So Class A members are visible to the Class B and invisible to the Class C.
Protected:
Protected is the same as Default but if a class extends then it is visible even if it is outside the package.
Class A members are visible to Class B because it is inside the package. For Class C it is invisible but if Class C extends Class A then the members are visible to the Class C even if it is outside the package.
Q #21) Difference between HashMap and HashTable.
Answer: Difference between HashMap and HashTable can be seen below:
HashMap |
HashTable |
Methods are not synchronized |
Key methods are synchronized |
Not thread safety |
Thread safety |
Iterator is used to iterate the values |
Enumerator is used to iterate the values |
Allows one null key and multiple null values |
Doesn’t allow anything that is null |
Performance is high than HashTable |
Performance is slow |
Q #22) Difference between HashSet and TreeSet.
Answer: Difference between HashSet and TreeSet can be seen below:
HashSet |
TreeSet |
Inserted elements are in random order |
Maintains the elements in the sorted order |
Can able to store null objects |
Couldn’t store null objects |
Performance is fast |
Performance is slow |
Q #23) Difference between Abstract class and Interface.
Answer: Difference between Abstract Class and Interface are as follows:
Abstract Class:
- Abstract classes have a default constructor and it is called whenever the concrete subclass is instantiated.
- It contains Abstract methods as well as Non-Abstract methods.
- The class which extends the Abstract class shouldn’t require the implementation of all the methods, only Abstract methods need to be implemented in the concrete sub-class.
- Abstract class contains instance variables.
Interface:
- It doesn’t have any constructor and couldn’t be instantiated.
- The abstract method alone should be declared.
- Classes that implement the interface should provide the implementation for all the methods.
- The interface contains only constants.
Q #24) What is mean by Collections in Java?
Answer: Collection is a framework that is designed to store the objects and manipulate the design to store the objects.
Collections are used to perform the following operations:
- Searching
- Sorting
- Manipulation
- Insertion
- Deletion
A group of objects is known as collections. All the classes and interfaces for collecting are available in Java util package.
Q #25) What are all the Classes and Interfaces that are available in the collections?
Answer: Given below are the Classes and Interfaces that are available in Collections:
Interfaces:
- Collection
- List
- Set
- Map
- Sorted Set
- Sorted Map
- Queue
Classes:
- Lists:
- Array List
- Vector
- Linked List
Sets:
- Hash set
- Linked Hash Set
- Tree Set
Maps:
- Hash Map
- Hash Table
- TreeMap
- Linked Hashed Map
Queue:
- Priority Queue
Q #26) What is meant by Ordered and Sorted in collections?
Answer:
Ordered: It means the values that are stored in a collection is based on the values that are added to the collection. So we can iterate the values from the collection in a specific order.
Sorted: Sorting mechanisms can be applied internally or externally so that the group of objects sorted in a particular collection is based on the properties of the objects.
Q #27) Explain the different lists available in the collection.
Answer: Values added to the list is based on the index position and it is ordered by index position. Duplicates are allowed.
Types of Lists are:
a) Array List:
- Fast iteration and fast Random Access.
- It is an ordered collection (by index) and not sorted.
- It implements the Random Access Interface.
Example:
public class Fruits{ public static void main (String [ ] args){ ArrayList names=new ArrayList (); names.add (“apple”); names.add (“cherry”); names.add (“kiwi”); names.add (“banana”); names.add (“cherry”); System.out.println (names); } } |
Output:
[Apple, cherry, kiwi, banana, cherry]
From the output, Array List maintains the insertion order and it accepts the duplicates. But not sorted.
b) Vector:
It is the same as Array List.
- Vector methods are synchronized.
- Thread safety.
- It also implements the Random Access.
- Thread safety usually causes a performance hit.
Example:
public class Fruit { public static void main (String [ ] args){ Vector names = new Vector ( ); names.add (“cherry”); names.add (“apple”); names.add (“banana”); names.add (“kiwi”); names.add (“apple”); System.out.println (“names”); } } |
Output:
[cherry,apple,banana,kiwi,apple]
Vector also maintains the insertion order and accepts the duplicates.
c) Linked List:
- Elements are doubly linked to one another.
- Performance is slower than the Array list.
- Good choice for insertion and deletion.
- In Java 5.0 it supports common queue methods peek( ), Pool ( ), Offer ( ) etc.
Example:
public class Fruit { public static void main (String [ ] args){ Linkedlist names = new linkedlist ( ) ; names.add(“banana”); names.add(“cherry”); names.add(“apple”); names.add(“kiwi”); names.add(“banana”); System.out.println (names); } } |
Output:
[ banana,cherry,apple,kiwi,banana]
Maintains the insertion order and accepts the duplicates.
Q #28) Explain about Set and their types in a collection?
Answer: Set cares about uniqueness. It doesn’t allow duplications. Here “equals ( )” method is used to determine whether two objects are identical or not.
a) Hash Set:
- Unordered and unsorted.
- Uses the hash code of the object to insert the values.
- Use this when the requirement is “no duplicates and don’t care about the order”.
Example:
public class Fruit { public static void main (String[ ] args){ HashSet names = new HashSet <=String>( ) ; names.add(“banana”); names.add(“cherry”); names.add(“apple”); names.add(“kiwi”); names.add(“banana”); System.out.println (names); } } |
Output:
[banana, cherry, kiwi, apple]
It doesn’t follow any insertion order. Duplicates are not allowed.
b) Linked Hash set:
- An ordered version of the hash set is known as Linked Hash Set.
- Maintains a doubly-Linked list of all the elements.
- Use this when the iteration order is required.
Example:
public class Fruit { public static void main (String[ ] args){ LinkedHashSet; names = new LinkedHashSet ( ) ; names.add(“banana”); names.add(“cherry”); names.add(“apple”); names.add(“kiwi”); names.add(“banana”); System.out.println (names); } } |
Output:
[banana, cherry, apple, kiwi]
It maintains the insertion order in which they have been added to the Set. Duplicates are not allowed.
c) Tree Set:
- It is one of the two sorted collections.
- Uses the “Read-Black” tree structure and guarantee that the elements will be in ascending order.
- We can construct a tree set with the constructor by using a comparable (or) comparator.
Example:
public class Fruits{ public static void main (String[ ]args) { Treeset names= new TreeSet( ) ; names.add(“cherry”); names.add(“banana”); names.add(“apple”); names.add(“kiwi”); names.add(“cherry”); System.out.println(names); } } |
Output:
[apple, banana, cherry, kiwi]
TreeSet sorts the elements in ascending order. And duplicates are not allowed.
Q #29). Explain about Map and their types.
Answer: Map cares about the unique identifier. We can map a unique key to a specific value. It is a key/value pair. We can search a value, based on the key. Like the set, Map also uses the “equals ( )” method to determine whether two keys are the same or different.
Map is of following types:
a) Hash Map:
- Unordered and unsorted map.
- Hashmap is a good choice when we don’t care about the order.
- It allows one null key and multiple null values.
Example:
Public class Fruit{ Public static void main(String[ ] args){ HashMap<Sting,String> names =new HashMap<String,String>( ); names.put(“key1”,“cherry”); names.put (“key2”,“banana”); names.put (“key3”,“apple”); names.put (“key4”,“kiwi”); names.put (“key1”,“cherry”); System.out.println(names); } } |
Output:
{key2 =banana, key1=cherry, key4 =kiwi, key3= apple}
Duplicate keys are not allowed in Map.
It doesn’t maintain any insertion order and is unsorted.
b) Hash Table:
- Like the vector key, methods of the class are synchronized.
- Thread safety and therefore slows the performance.
- It doesn’t allow anything that is null.
Example:
public class Fruit{ public static void main(String[ ]args){ Hashtable<Sting,String> names =new Hashtable<String,String>( ); names.put(“key1”,“cherry”); names.put(“key2”,“apple”); names.put(“key3”,“banana”); names.put(“key4”,“kiwi”); names.put(“key2”,“orange”); System.out.println(names); } } |
Output:
{key2=apple, key1=cherry,key4=kiwi, key3=banana}
Duplicate keys are not allowed.
c) Linked Hash Map:
- Maintains insertion order.
- Slower than Hash map.
- I can expect a faster iteration.
Example:
public class Fruit{ public static void main(String[ ] args){ LinkedHashMap<Sting,String> names =new LinkedHashMap<String,String>( ); names.put(“key1”,“cherry”); names.put(“key2”,“apple”); names.put(“key3”,“banana”); names.put(“key4”,“kiwi”); names.put(“key2”,“orange”); System.out.println(names); } } |
Output:
{key2=apple, key1=cherry,key4=kiwi, key3=banana}
Duplicate keys are not allowed.
d) TreeMap:
- Sorted Map.
- Like Tree set, we can construct a sort order with the constructor.
Example:
public class Fruit{ public static void main(String[ ]args){ TreeMap<Sting,String> names =new TreeMap<String,String>( ); names.put(“key1”,“cherry”); names.put(“key2”,“banana”); names.put(“key3”,“apple”); names.put(“key4”,“kiwi”); names.put(“key2”,“orange”); System.out.println(names); } } |
Output:
{key1=cherry, key2=banana, key3 =apple, key4=kiwi}
It is sorted in ascending order based on the key. Duplicate keys are not allowed.
Q #30) Explain the Priority Queue.
Answer: Queue Interface
Priority Queue: Linked list class has been enhanced to implement the queue interface. Queues can be handled with a linked list. The purpose of a queue is “Priority-in, Priority-out”.
Hence elements are ordered either naturally or according to the comparator. The elements ordering represents their relative priority.
Q #31) What is meant by Exception?
Answer: An Exception is a problem that can occur during the normal flow of execution. A method can throw an exception when something wails at runtime. If that exception couldn’t be handled, then the execution gets terminated before it completes the task.
If we handled the exception, then the normal flow gets continued. Exceptions are a subclass of java.lang.Exception.
Q #32) What are the types of Exceptions?
Answer: There are two types of Exceptions. They are explained below in detail.
a) Checked Exception:
These exceptions are checked by the compiler at the time of compilation. Classes that extend Throwable class except Runtime exception and Error are called checked Exception.
Checked Exceptions must either declare the exception using throws keyword (or) surrounded by appropriate try/catch.
For Example, ClassNotFound Exception
b) Unchecked Exception:
These exceptions are not checked during the compile time by the compiler. The compiler doesn’t force to handle these exceptions. It includes:
• Arithmetic Exception
• ArrayIndexOutOfBounds Exception
Q #33) What are the advantages of Exception handling?
Answer: The advantages are as follows:
• The normal flow of the execution won’t be terminated if exception got handled
• We can identify the problem by using catch declaration
Q #34) What is the final keyword in Java?
Answer:
Final variable: Once a variable is declared as final, then the value of the variable could not be changed. It is like a constant.
Example:
final int = 12;
Final method: A final keyword in a method, couldn’t be overridden. If a method is marked as a final, then it can’t be overridden by the subclass.
Final class: If a class is declared as final, then the class couldn’t be subclassed. No class can extend the final class.