Skip to main content

Posts

Abstract Class and Interface Interview Questions And Answers - Programming Blog

abstract class and Interface interview questions and answers in java Lets see most asked interview questions and answers about interface and abstract class in java.  1. What is Interface in Java? Ans :- Interface is completely Abstract Class. From java 8, we can use default method in interface. Interface is just declarations of methods. Interface does not provide implementation of methods. We can implement interface and whoever class implements that interface it must provide implementation of that interface. Any class implements as many interface they want. Interface also can extends another interface. but one interface can not implements another interface. Learn more about Interface with Examples :- Interface In Java 2. What is Abstract class in Java? Ans :-  Any class defined with abstract keyword is called abstract class. Abstract class contains abstract method as well as non abstract methods also. Abstract class can not instantiated means we can not create object of abstr...

Top 5 Reasons Why Python is Popular

In this article we cover why python is popular. so many people talking about python when it comes to programming language? Why Python programming is so popular? There are plenty of reasons why python is popular but we cover only main top reasons. You can see StackOverflow survey for 2019. StackOverflow 2019 developer survey You can see StackOverflow survey for 2020. StackOverflow 2020 developer survey You can full insight which programming language is most lovable, used or dead. You can also see which framework is most lovable, used or dead by developers survey. So now lets go for Why Python is become popular nowadays? 1.Python language is simple and easy for beginners. You know also python is so simple and easy when it comes to other languages. So many beginner programmers choose python for development. And also its syntax is so easy then other programming language. like in java if you want to simple run "Hello World" example you have to define class define main method and t...

Difference between Final, Finally and Finalize in Java

In your java journey sometimes you confuse about these three final words. but now we remove this confusion in this article. so lets go differentiate these three terms. What is final, finally and finalize in simple terms? Final :- Final is keyword in java. final means it can not be changeable. We can use final keyword in following three cases:- Final Class Final Variable Final Method If we declare class as final then we can not extends that class. if we try to extends final class then we get error. If we declare variable as final means we can not reassign its value means we can not change if we declare variable final. And last id we declare method as final then we can not override that methods. means can not overridden final method. I created full article about Final keyword in java you can check here. FINAL KEYWORD IN JAVA Finally :- Finally is block in java. It is simple block. Finally {     // Finally block     System.out.print("In finally block"); }

Final keyword in Java (Final class, method and variable)

In this article we discuss about what is final keyword, why final keyword is used. What is final in Java? | What is final class, method and variable? In java final is like constant. In java final keyword used with following ways:- final class final variable final methods If final used in java following restriction happens:- If final use with class then that class can not inherited. If final use with variable then we can not change its value. If final use with method then we can not override. In java, String is immutable means we can not change its value. You can see String class is final class. Lets see all of them. Final Class When class declared with final keyword, it is called final class. If class declared with final then that class does not inherited means another class can not extends final class. If we extends final class then it programs give compile time error. Example :- Final Class final class FinalClass {     } public class FinalDemo extends FinalClass{  ...

Static keyword in Java (Static class, variable, method and block)

In this blog we learn about Static Class, Variables, Methods and Block in Java. What is Static Keyword in Java? | What is static class, variable, method and block in java? Static keyword is used for memory management in java. Static keyword used in java with class, variables, methods. We can also use static block in java. Static members are class specific means we can directly access without creating object of class. that is main advantage of static. We can directly use static members using class. In java, Math class have almost static data member using that we can directly work on math function without creating object of that. Static keyword is reserved in java means we can not used as identifiers. Static can be from following :- Static Class Static Variables Static Methods Static Blocks Example :- Static demo using Math class method and variable. class StaticDemo{     public static void main(String args[]) {         double piValue = Math.P...

Interface in Java with examples

In java there is another way for achieve Abstraction , That is using Interface. What is Interface in Java? Interface is like java class, but interface has only abstract method and static constants. Interface is used for implement multiple inheritance. multiple inheritance is not supported in java. In simple word Interface is used to achieve multiple inheritance and abstraction. Learn more about Abstraction. All method in interface are public and abstract. Interface only contains abstract method means method does not contain its body. A java class can implement multiple interface. Syntax of Interface Interface interface_name {         // Constants variables.     // Method declaration without body. } Like abstraction, Interface also does not have method body. But interface contains method declaration, Default, Constants and Static methods. Interface is implements by class and then class provides implementation of abstract methods. Interface ca...