Hi in this post we are going to discuss TPF software Java Fresher Interview Questions with Answers. Let us see the technical questions asked to the candiates briefly in this post;

 TPF software Java Fresher Interview Questions with Answers

1.Write a program in Java string to print the result as TPF software.

SAMPLE CODE:
import java.util.Scanner;

public class JavaProgram
{
public static void main(String args[])
{
String str;
Scanner scan = new Scanner(System.in);

System.out.print(“TPF software”);
}
}
SAMPLE OUTPUT:
TPF software

2.Explain Exception handling and it’s usage.

EXCEPTION HANDLING:
=>In Java, an exception is an event that disrupts the normal flow of the program. It is an object which is thrown at runtime.
=>Exception Handling is a mechanism to handle runtime errors such as ClassNotFound, IO, SQL, Remote etc.
=>Java exception handling is managed via five keywords: try, catch, throw, throws, and finally.except
USAGE OF EXCEPTION HANDLING:
=>The core advantage of exception handling is to maintain the normal flow of the application. 
=>It helps to propagate error reporting up the call stack of methods.
=>It groups and differentiates various types of errors.

3.List out the Difference between overloading and overridingover vs

    METHOD OVERLOADING

       METHOD OVERRIDING

·    Method overloading is used to increase the readability of the program. ·    Method overriding is used to provide the specific implementation of the method that is already provided by its super class.

 

·    Method overloading is performed within class. ·    Method overriding occurs in two classes that have IS-A (inheritance) relationship.
·    In case of method overloading, parameter must be different. ·    In case of method overriding, parameter must be same.
·    Method overloading is the example of compile time polymorphism. ·    Method overriding is the example of run time polymorphism.
·    Return type can be same or different in method overloading.  ·    Return type must be same or covariant in method overriding.
EXAMPLE:

class OverloadingExample{  

static int add(int a,int b){return a+b;}  

static int add(int a,int b,int c){return a+b+c;}  

}  

 

EXAMPLE:

class Animal{  

void eat(){System.out.println(“eating…”);}  

}  

class Dog extends Animal{  

void eat(){System.out.println(“eating bread…”);}  

 

 

4.Tell me object oriented concepts in Java.

=>Object Oriented Programming popularly known as OOP, is used in a modern programming language like Java.
=>It works on the principle that objects are the vital part of your program.
=>It allows users create the objects that they want and then create methods to handle those objects.java-oops
=>The following are the Object-Oriented concepts in java:
1]Object
An Object can be defined as an instance of a class. An object contains an address and takes up some space in memory. Objects can communicate without knowing the details of each other’s data or code.
2]Class
Collection of objects is called class. It is a logical entity that can also be defined as a blueprint from which you can create an individual object.
3]Inheritance
When one object acquires all the properties and behaviors of a parent object, it is known as inheritance. It provides code reusability and used to achieve runtime polymorphism.
4]Abstraction
Hiding internal details and showing functionality is known as abstraction. In Java, we use abstract class and interface to achieve abstraction.
5]Encapsulation
Binding (or wrapping) code and data together into a single unit are known as encapsulation. A java class is the example of encapsulation.

Advantages of OOPS:
=>Easy to understand and a clear modular structure for programs.
=>Reusability of objects in other programs, saving significant development cost.
=>It also enhances program modularity because every object exists independently.

5.What is Polymorphism?

=>Any Java object that can pass more than one IS-A test is considered to be polymorphic.
=>In Java, all Java objects are polymorphic since any object will pass the IS-A test for their own type and for the class Object.polymorphism
TYPES OF POLYMORPHISM:
=>Runtime Polymorphism(or Dynamic polymorphism)
Runtime polymorphism is a process in which a call to an overridden method is resolved at runtime rather than compile-time.Method overriding is an example of compile time polymorphism.
=>Compile time Polymorphism (or Static polymorphism)
Polymorphism that is resolved during compiler time is known as static polymorphism. Method overloading is an example of compile time polymorphism.POLY
ADVANTAGES OF POLYMORPHISM:
=>It increases reusability of the programs.
=>Single variable name can be used to store variables of multiple data types.
=>Polymorphism helps in reducing the coupling between different functionalities.

References:
https://codescracker.com/java/program/java-program-print-string.htm
https://docs.oracle.com/javase/tutorial/essential/exceptions/advantages.html
https://www.javatpoint.com/method-overloading-vs-method-overriding-in-java
https://beginnersbook.com/2013/04/runtime-compile-time-polymorphism/
https://www.tutorialspoint.com/java/java_polymorphism.htm