OOPS Interview Questions:-


  1. What are different oops concept in java?

OOPs stands for Object Oriented Programming. The concepts in oops are similar to any other programming languages. Basically, it is program agnostic.

The different OOps concepts are :

1. Polymorphism

2. Inheritance

3. Abstraction

4. Encapsulation

5. Aggreagation

6. Composition

7. Association



  2. What is polymorphism?

The ability to identify a function to run is called Polymorphism. In java, c++ there are two types of polymorphism: compile time polymorphism (overloading) and runtime polymorphism (overriding).

Mehtod overriding: Overriding occurs when a class method has the same name and signature as a method in parent class. When you override methods, JVM determines the proper methods to call at the program's run time, not at the compile time.

Method Overloading: Overloading is determined at the compile time. It occurs when several methods have same names with:

1. Different method signature and different number or type of parameters.

2. Same method signature but different number of parameters.

3. Same method signature and same number of parameters but of different type



  3. What is inheritance?

Inheritance allows a Child class to inherit properties from its parent class. In Java this is achieved by using extends keyword. Only properties with access modifier public and protected can be accessed in child class.



  4. What is multiple inheritance and does java support?

If a child class inherits the property from multiple classes is known as multiple inheritance. Java does not allow to extend multiple classes.

The problem with with multiple inheritance is that if multiple parent classes has a same method name, the at runtime it becomes diffcult for compiler to decide which method to execute from the child class.

To overcome this problem it allows to implement multiple Interfaces. The problem is commonly referred as What is Diamond Problem.



  5. What is difference between polymorphism and inheritance?

1. Inheritance defines parent-child relationship between two classes, polymorphism take advantage of that relationship to add dynamic behaviour in your code.

2. Inheritance helps in code reusability by allowing child class to inherit behavior from the parent class. On the other hand Polymorphism allows Child to redefine already defined behaviour inside parent class. Without Polymorphism it's not possible for a Child to execute its own behaviour while represented by a Parent reference variable, but with Polymorphism he can do that.

3. Java doesn't allow multiple inheritance of classes, but allows multiple inheritance of Interface, which is actually require to implement Polymorphism. For example a Class can be Runnable, Comparator and Serializable at same time, because all three are interfaces. This makes them to pass around in code e.g. you can pass instance of this class to a method which accepts Serializable, or to Collections.sort() which accepts a Comparator.

4. Both Polymorphism and Inheritance allow Object oriented programs to evolve. For example, by using Inheritance you can define new user types in an Authentication System and by using Polymorphism you can take advantage of already written authentication code. Since, Inheritance guarantees minimum base class behaviour, a method depending upon super class or super interface can still accept object of base class and can authenticate it.



  6. What is an abstraction ?

Abstraction is a way of converting real world objects in terms of class. Its a concept of defining an idea in terms of classes or interface. For example creating a class Vehicle and injecting properties into it.



  7. What is Encapsulation?

The encapsulation is achieved by combining the methods and attribute into a class. The class acts like a container encapsulating the properties.

The users are exposed mainly public methods.The idea behind is to hide how thinigs work and just exposing the requests a user can do.



  8. What is Association?

Association is a relationship where all object have their own lifecycle and there is no owner. Let's take an example of Teacher and Student.

Multiple students can associate with single teacher and single student can associate with multiple teachers but there is no ownership between the objects and both have their own lifecycle. Both can create and delete independently.



  9. What is Aggregation?

Aggregation is a specialize form of Association where all object have their own lifecycle but there is ownership and child object can not belongs to another parent object.

Let's take an example of Department and teacher. A single teacher can not belongs to multiple departments, but if we delete the department teacher object will not destroy. We can think about "has-a" relationship.



  10. What is Composition ?

Composition is again specialize form of Aggregation and we can call this as a "death" relationship. It is a strong type of Aggregation.

Child object dose not have their lifecycle and if parent object deletes all child object will also be deleted. Let's take again an example of relationship between House and rooms.

House can contain multiple rooms there is no independent life of room and any room can not belongs to two different house if we delete the house room will automatically delete.



  11. What is method hiding in Java?

When you declare two static methods with same name and signature in both superclass and subclass then they hide each other i.e. a call to the method in the subclass will call the static method declared in that class and a call to the same method is superclass is resolved to the static method declared in the super class.



  12. Is Java a pure object oriented language? if not why?

Java is not a pure object-oriented programming language e.g. there are many things you can do without objects e.g. static methods. Also, primitive variables are not objects in Java. See the answer for a more detailed explanation.



  13. What are rules of method overloading and overriding in Java?

One of the most important rule of method overloading in Java is that method signature should be different i.e. either the number of arguments or the type of arguments. Simply changing the return type of two methods will not result in overloading, instead compiler will throw an error.

On the other hand, method overriding has more rules e.g. name and return type must be same, method signature should also be same, the overloaded method cannot throw a higher exception etc. See the answer for a full list of rules related to method overloading and overriding in Java.



  14. The difference between method overloading and overriding?

Several differences but the most important one is that method overloading is resolved at compile time and method overriding is resolved at runtime.

The compiler only used the class information for method overloading, but it needs to know object to resolved overridden method calls.



  15. Can we overload a static method in Java?

Yes, you can overload a static method in Java. You can declare as many static methods of the same name as you wish provided all of them have different method signatures.



  16. Can we override static method in Java?

No, you cannot override a static method because it's not bounded to an object. Instead, static methods belong to a class and resolved at compile time using the type of reference variable.

But, Yes, you can declare the same static method in a subclass, that will result in method hiding i.e. if you use reference variable of type subclass then new method will be called, but if you use reference variable of superclass than old method will be called.



  17. Can we prevent overriding a method without using the final modifier?

Yes, you can prevent the method overriding in Java without using the final modifier. In fact, there are several ways to accomplish it e.g. you can mark the method private or static, those cannot be overridden.



  18. Can we override a private method in Java?

No, you cannot. Since the private method is only accessible and visible inside the class they are declared, it's not possible to override them in subclasses. Though, you can override them inside the inner class as they are accessible there.



  19. What is covariant method overriding in Java?

In covariant method overriding, the overriding method can return the subclass of the object returned by original or overridden method.

This concept was introduced in Java 1.5 (Tiger) version and it's very helpful in case original method is returning general type like Object class, because, then by using covariant method overriding you can return more suitable object and prevent client side type casting. One of the practical use of this concept is in when you override the clone() method in Java.



  20. What is inheritance?Can we change the return type of method to subclass while overriding?

Yes, you can, but only from Java 5 onward. This feature is known as co-variant method overriding and it was introduced in JDK 5 release.

This is immensely helpful if original method return super-class e.g. clone() method return java.lang.Object. By using this, you can directly return the actual type, preventing client-side type casting of the result.



  21. Can we change the argument list of an overriding method?

No, you cannot. The argument list is part of the method signature and both overriding and overridden method must have the same signature.



  22. Can we override a method which throws runtime exception without throws clause? `

Yes, there is no restriction on unchecked exception while overriding. On the other hand, in the case of checked exception, an overriding exception cannot throw a checked exception which comes higher in type hierarchy e.g. if original method is throwing IOException than overriding method cannot throw java.lang.Exception or java.lang.Throwable.



  23. How do you call superclass version of an overriding method in sub class?

You can call a superclass version of an overriding method in the subclass by using super keyword. For example to call the toString() method from java.lang.Object class you can call super.toString().



  24. Can we override a non-static method as static in Java?

Yes, you can override the non-static method in Java, no problem on them but it should not be private or final :)



  25. Can we override the final method in Java?

No, you cannot override a final method in Java, final keyword with the method is to prevent method overriding. You use final when you don't want subclass changing the logic of your method by overriding it due to security reason.

This is why String class is final in Java. This concept is also used in template design pattern where template method is made final to prevent overriding.



  26. Can we have a non-abstract method inside interface?

From Java 8 onward you can have a non-abstract method inside interface, prior to that it was not allowed as all method was implicitly public abstract. From JDK 8, you can add static and default method inside an interface.



  27. What is the default method of Java 8?

Default method, also known as extension method are new types of the method which you can add on the interface now. These method has implementation and intended to be used by default.

By using this method, JDK 8 managed to provide common functionality related to lambda expression and stream API without breaking all the clients which implement their interfaces.

If you look Java 8 API documentation you will find several useful default method on key Java interface like Iterator, Map etc.



  28. What is difference between Abstract class and interface?

In Java, the key difference is that abstract class can contain non-abstract method but the interface cannot, but from Java 8 onward interface can also contain static and default methods which are non-abstract



  29. Can we make a class both final and abstract at the same time?

No, you cannot apply both final and abstract keyword at the class same time because they are exactly opposite of each other. A final class in Java cannot be extended and you cannot use an abstract class without extending and making it a concrete class.

As per Java specification, the compiler will throw an error if you try to make a class abstract and final at the same time.



  30. Can we overload or override the main method in Java?

No, since main() is a static method, you can only overload it, you cannot override it because the static method is resolved at compile time without needing object information hence we cannot override the main method in Java.



  31. What is the difference between Polymorphism, Overloading, and Overriding?

This is slight tricky OOP concept question because Polymorphism is the real concept behind on both Overloading and Overriding. Overloading is compile time Polymorphism and Overriding are runtime Polymorphism.



  32. What problem is solved by Strategy pattern in Java?

Strategy pattern allows you to introduce new algorithm or new strategy without changing the code which uses that algorithm. For example, the Collections.sort() method which sorts the list of the object uses Strategy pattern to compare object.

Since every object uses different comparison strategy you can compare various object differently without changing sort method.



  33. When to use Singleton design pattern in Java?

When you need just one instance of a class and wants that to be globally available then you can use Singleton pattern. It's not free of cost though because it increase coupling between classes and make them hard to test.

This is one of the oldest design pattern questions from Java interviews. Please see the answer for more detailed discussion.



  34. What is the difference between State and Strategy Pattern?

Though the structure or class diagram of State and Strategy pattern is same, their intent is completely different. State pattern is used to do something specific depending upon state while Strategy allows you to switch between algorithms without changing the code which uses it.



  35. What is the difference between Association, Aggregation, and Composition in OOP?

When an object is related to another object it called association. It has two forms, aggregation, and composition. the former is the loose form of association where the related object can survive individual while later is a stronger form of association where a related object cannot survive individually. For example, the city is an aggregation of people but is the composition of body parts.



  36. What is the difference between Decorator, Proxy and Adapter pattern in Java?

Again they look similar because their structure or class diagram is very similar but their intent is quite different.

Decorator adds additional functionality without touching the class, Proxy provides access control and Adapter is used to make two incompatible interfaces work together.



  37. What is the 5 objects oriented design principle from SOLID?

SOLID is the term given by Uncle Bob in his classic book, the Clean Code, one of the must-read books for programmers.

In SOLID each character stands for one design principle:

1. S for Single Responsibility Principle

2. O for Open closed design principle

3. L for Liskov substitution principle

4. I for Interface segregation principle

5. D for Dependency inversion principle



  38. What is the difference between Composition and Inheritance in OOP?

This is another great OOPS concept question because it test what matters, both of them are very important from a class design perspective. Though, both Composition and Inheritance allows you to reuse code, former is more flexible than later.

Composition allows the class to get an additional feature at runtime, but Inheritance is static. You can not change the feature at runtime by substitution new implementation. See the answer for more detailed discussion



  39. What is Constructor?

A is special method of the class that will be automatically invoked when an instance of the class is created is called as constructor.

Constructors are mainly used to initialize private fields of the class while creating an instance for the class.

When you are not creating a constructor in the class, then compiler will automatically create a default constructor in the class that initializes all numeric fields in the class to zero and all string and object fields to null.



  40. Types of Constructors

Basically constructors are 5 types those are

1. Default Constructor

2. Parameterized Constructor

3. Copy Constructor

4. Static Constructor

5. Private Constructor



  41. Define Destructor?

A destructor is a method which is automatically invoked when the object is destroyed.

Its main purpose is to free the resources (memory allocations, open files or sockets, database connections, resource locks, etc.).



  42. What is Inline function?

In the C and C++ programming languages, an inline function is one qualified with the keyword inline; this serves two purposes.

Firstly, it serves as a compiler directive, which suggests (but does not require) that the compiler substitute the body of the function inline by performing inline expansion, The second purpose of inline is to change linkage behavior; the details of this are complicated.



  43. What is operator overloading?

In programming, operator overloading—less commonly known as operator ad hoc polymorphism—is a specific case of polymorphism, where different operators have different implementations depending on their arguments.

Operator overloading is generally defined by the language, the programmer, or both.



  44. What is this keywords?

Every instance method in every object in Java receives a reference named this when the method is invoked. The reference named this is a reference to the object on which the method was invoked.

It can be used for any purpose for which such a reference is needed.



  45. What is super keyword?

The super keyword is a reference variable that is used to refer immediate parent class object.

Whenever you create the instance of subclass, an instance of parent class is created implicitly i.e. referred by super reference variable.



  46. What is final keywords?

The final keyword in java is used to restrict the user. The java final keyword can be used in many context. Final can be: variable, method, class.

The final keyword can be applied with the variables, a final variable that have no value it is called blank final variable or uninitialized final variable.

It can be initialized in the constructor only. The blank final variable can be static also which will be initialized in the static block only.



  47. Can you give some examples of tokens?

Some of the examples of tokens are:

1. Keywords

2. Identifiers

3. Constants

4. Operators

5. Brackets

6. Commas



  48. Define Modularity?

It is the property of big a system divided into small modules which can be integrated as per the requirement.

Explain: a.) Persistence. b.) Colloboration

a.) Persistence.

It is the property of an object which extends its existence into space and time.

b.) Colloboration

Process by which several objects co-operate to deliver a higher level result.



  49. What is a ternary operator?

It is also called as a conditional operator.

It is an operator that can take three arguments.

The data types of arguments and results are different.



  50. How a program can be structured using the concept of Object oriented programming?

The program can be structured by splitting the one big task into subtasks, create some function for the tasks that has to be worked upon and then write a program to instruct the computer to perform the desired calculations on the basis of which the output will be generated.

As, the large amount of data or tasks will be separated into less complex programs then it will be easier to manage. In object oriented program the program structure is maintained according to the objects made up from the class.

Every function is in a particular class that has an object calling certain properties and methods for implementation. It can manage the complexity of the large pieces and will be able to create a modular approach towards the programming methodology.



  51. What are the features that are provided to make a program modular?

To create a program requires self sufficient resources, the way to make a piece of code modular so that it can be handled properly. This shows the relationship between different objects or in between the same objects. Different functions have to be used to keep the code different from the data provided. Object oriented programming allows creating a modular approach to make it more abstract and create the interactions between them.

The features that are being provided in object oriented programming is:

Encapsulation: it deals with the grouping of data and functions together at one place or it can be said in an object that defines the interface of their interaction and the relationship between them.

Inheritance: it deals with the relationship that exists between the parent and child classes. A child can inherit the properties of the parent and it remains helpful in creating a hierarchy in the system to keep things more modular.

Polymorphism: is a feature that deals with different values that can be used by only one function. It doesn't have to re-create the same function again and again for different values but, it uses the same function to call different data types.



  52. What is the function of pure virtual functions?

Pure virtual function in object oriented programming is called as virtual method that acts as a function allowing its behavior to be overridden by the class that is inheriting the pure virtual function with the same signature. This is used in case of polymorphism.

It is used when a base class is being driven by the derived class and an object of the derived class referred as base or derived class type. When a derived class overrides the base class method then the output or the behavior will be called as ambiguous.

To use the virtual function a virtual keyword is used. This allows the function to be defined in every derived class and use the functionality of it.



  53. What is the difference between data hiding and implementation?

Data hiding is the concept of hiding the data from the other objects. It allows the data to be hidden from other objects that can prevent the use of any other objects. This way the direct manipulation of the object can't be done and the cell will hide the internal mechanism of it.

A method uses an interface such as primary, public, etc. The implementation keeps the separate out data and let the user implement the structure or the data that is being provided already.

Implementation allows the object to be changes according to the requirement. It deals with objects communication via messages in which when a target object then the implementation can be done with the method.



  54. What are the properties that are defined in an Object model?

Object oriented programming always consists of an object model that includes state and behavior. The state defines the present condition of the system or an entity. The behavior includes the data and the operations that are performed on those data.

Object represents the group of related functions and data structure that is used to give functionality to the functions. The functions that are being represented are the object models. It consists of the data structure, data type and the instance variables.

Methods are used to hide the variables from the user and and define a high level in object model. Object model also consists of the flow properties through which the object can be accessed with a defined relationship.



  55. What is the function of messaging metaphor?

Object oriented programming is having its own metaphors that are associated with the program or the code that has a role to play in the program. Messaging metaphor represent the relationship between the actors that are involved it and the roles each are playing.

This allows easy passing of the responsibilities and information to the processes that are in contact with the one which is passing the information. Messaging method allows the user to use the objects rather than their functions. As, the objects perform all the actions that is been done by the methods or the functions alone.

Objects consists of state and behavior so they are not active rather passive, but they act as an agent to allow the program's activity to be performed easily. This metaphor keeps all the objects separate each with the defined roles.



  56. Why is class hierarchies managed in object-oriented programming?

Class is used to store some methods and behavior. Class is used to access through an object and create a relationship between all the subclasses. A class can be made a super class of another classes that are present will be called as the subclass of it.

Many classes can be linked together in a hierarchy of inheritance. The inheritance hierarchy consists of a root class and this is also called as the super class. The root class hierarchy sends the branch downwards. This class inherits the features from the super class and from all the other classes that are at the top level in the hierarchy.

Each class consists of the class definition and the properties that are inherited from other classes. Every class consists of one super class and can consist of any number of subclasses.



  57. What are the methods required to create changes in Subclasses?

Subclass is a class that is under the super class and it inherits the property of the subclass as well. The class definition can be expanded by using the class definition that inherits the methods and variables that are used in the program. The subclasses consist of their own methods and variables with the super class variables as well. The methods that are used:

.Subclass can modify the behavior that it inherits from the existing method.

.Subclass can extend the behavior of the object by inheriting the new methods and functionalities. Subclass overrides any method that is being taken from the super class.

.Subclass fills the super class properties to make it more specific and specialized. There is addition of program or code take place and the replacement occurs only at the time of new functionalities coming up.



  58. What is the function of dynamic typing?

Dynamic typing is a way to allow the compiler to replace an existing value with a type that is not functioning properly. There can be warning signs like: incompatible types in assignment.

This warning sign shows that there is type checking that casts the object from one to another to make it compatible with the current system. The dynamic typing checks for the type of object that is being during the compile time and during the run time the value doesn't change.

If the class of the variable can be found during the run time then it will be possible to find out the class of the variable. Dynamic binding provides the output to the dynamic binding. It allows the binding between the objects to be done at runtime.



  59. Why dynamic binding is used in object-oriented programming?

Dynamic binding allows delaying the decision of running the program. Dynamic binding is used to perform messaging transparently and routinely by allowing different objects to be binded on the run time. It allows the declared pointer to find out the assigned values of a give procedure.

Messages that are given with the programs are invoked indirectly. Every method has a message expression that has to be found for implementation.

The class of the receiver is checked to locate the implementation of the method that is mentioned in the message. When at run time the method is run then the complier dynamically bind the objects.



  60. What is the purpose of late binding in object-oriented programming?

Late binding is done at the run time and it requires the messages to be passed to the receiver statically by writing in the code or the program. An object can be attached to its own class or any class that inherits the properties of the class.

The compiler has difficulty in understanding whether the source is specified in the type declaration or not. As, if an object is given then on run time it is not possible for the compiler to know its class then for that the instance of the specified class is binded with the method that is defined for that particular class to the messages.

The late binding is done during the linking of the method to the procedure of the program. It consists of strict compile time rules that put the constraints on the program in execution.



  61. What are access modifiers?

Access modifiers determine the scope of the method or variables that can be accessed from other various objects or classes. There are 5 types of access modifiers , and they are as follows:.

1. Private.

2. Protected.

3. Public.

4. Friend.

5. Protected Friend.



  62. What is sealed modifiers?

Sealed modifiers are the access modifiers where it cannot be inherited by the methods. Sealed modifiers can also be applied to properties, events and methods. This modifier cannot be applied to static members.



  63. What is the difference between new and override?

The new modifier instructs the compiler to use the new implementation instead of the base class function. Whereas, Override modifier helps to override the base class function.



  64. What is static and dynamic binding?

Binding is nothing but the association of a name with the class. Static binding is a binding in which name can be associated with the class during compilation time , and it is also called as early Binding.

Dynamic binding is a binding in which name can be associated with the class during execution time , and it is also called as Late Binding.


  65. What are the advantages of OOPS concepts?

Major advantages of OOPS programming are;

1. Simplicity: OOPS programming objects model real world objects, so the complexity is reduced and the program structure is clear.

2. Modularity: Each object forms a separate entity whose internal workings are decoupled from other parts of the system.

3. Modifiability: It is easy to make minor changes in the data representation or the procedures in an OO program. Changes inside a class do not affect any other part of a program, since the only public interface that the external world has to a class is through the use of methods.

4. Extensibility: Adding new features or responding to changing operating environments can be solved by introducing a few new objects and modifying some existing ones.

5. Maintainability: Objects can be maintained separately, making locating and fixing problems easier.

6. Reusability: Objects can be reused in different programs.



  66. What is the difference between Procedural programming and OOPS?

1. Procedural language is based on functions but object oriented language is based on real world objects.

2. Procedural language gives importance on the sequence of function execution but object oriented language gives importance on states and behaviors of the objects.

3. Procedural language exposes the data to the entire program but object oriented language encapsulates the data.

4. Procedural language follows top down programming paradigm but object oriented language follows bottom up programming paradigm.

5. Procedural language is complex in nature so it is difficult to modify, extend and maintain but object oriented language is less complex in nature so it is easier to modify, extend and maintain.

6. Procedural language provides less scope of code reuse but object oriented language provides more scope of code reuse.



  67. What is the diamond problem in inheritance?

In case of multiple inheritance, suppose class A has two subclasses B and C, and a class D has two super classes B and C.If a method present in A is overridden by both B and C but not by D then from which class D will inherit that method B or C? This problem is known as diamond problem.



  68. What is Dependency?

When one class depends on another because it uses that at some point in time then this relationship is known as Dependency. One class depends on another if the independent class is a parameter variable or local variable of a method of the dependent class. A Dependency is drawn as a dotted line from the dependent class to the independent class with an open arrowhead pointing to the independent class.



  69. What are the Object Characteristics?

The three key characteristics of Object are

1. State

2. Behavior

3. Identity

State

. Instance variables value is called object state.

. An object state will be changed if instance variables value is changed.

Behavior

. Behavior of an object is defined by instance methods.

. Behavior of an object is depends on the messages passed to it.

. So an object behavior depends on the instance methods.

Identity

. Identity is the hashcode of an object, it is a 32 bit integer number created randomly and assigned to an object by default by JVM.

. Developer can also generate hashcode of an object based on the state of that object by overriding hashcode() method of java.lang.Object class.

. Then if state is changed , automatically hashcode will be changed.



  70. How can we call the base method without creating an instance?

Yes, it is possible to call the base method without creating an instance. And that method should be,. Static method.

Doing inheritance from that class.-Use Base Keyword from derived class.


  71. What is dynamic or run time polymorphism?

Dynamic or Run time polymorphism is also known as method overriding in which call to an overridden function is resolved during run time, not at the compile time. It means having two or more methods with the same name,same signature but with different implementation.



  72. How inheritance implemented in java?

1. Inheritance can be implemented in JAVA using below two keywords.

. extends

. implements

2. extends is used for developing inheritance between two classes or two interfaces, and implements keyword is used to develop inheritance between interface and class.

package com.instanceofjava;
class A{
}

package com.instanceofjava;
class B extends A{
}



  73. What are the types of inheritances?

There are two types of inheritance

1. Multilevel Inheritance

2. Multiple Inheritance

Multilevel Inheritance:

Getting the properties from one class object to another class object level wise with some priority is known as multilevel inheritance.

Multiple Inheritance:

The concept of getting multiple class objects to single class object is known as multiple inheritance. multiple inheritance is not supported by java



  74. Similarities and differences between this and super keywords?

this:

1. This is a keyword used to store current object reference.

2. It must be used explicitly if non -static variable and local variables name is same.

3. System.out.print(this); works fine

super:

1. Super is a keyword used to store super class non -static members reference in sub class object.

2. used to separate super class and sub class members if both have same name.

3. System.out.println(super); compilation Error



  75. What is JIT (Just-in-Time) Compilation ?

There are two ways a language can be compiled

1. Compiled Language

2. Interpreted Language

A machine understands only binary language, so finally a source code has to be compiled in binary format. In compiled way the compiler directly generate the binary file from source code.While in interpreted way it generate the class file which is then run by virtual machine.

That means binary file is generated at the run time (compilation is done on need basis) this type of compilation is called JIT (Just-in-Time) compilation.



  76. What are Abstract methods ?

An abstract class can have abstract methods. You declare a method abstract by adding the abstract keyword in front of the method declaration. Abstract method do not have implementation. Abstract method should be implemented in the sub class which inherit them.

public abstract class MyAbstractClass {
public abstract void abstractMethod();
}


PHP

PHP is a server-side scripting language designed primarily for web development but is also used as a general-purpose programming language..

Read more