Skip to content

codinggyan/200-core-java-interview-questions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 

Repository files navigation

200-core-java-interview-questions

Blue Gradient Modern Freelancer YouTube Thumbnail  (3)

Table of Contents

No. Questions
1 What are static blocks and static initalizers in Java
2 How to call one constructor from the other constructor
3 What is method overriding in java
4 What is super keyword in java
5 Difference between method overloading and method overriding in java
6 Difference between abstract class and interface
7 Why java is platform independent
8 What is method overloading in java
9 What is difference between c++ and Java
10 What is JIT compiler
11 What is bytecode in java
12 Difference between this() and super() in java
13 What is a class
14 What is an object
15 What is method in java
16 What is encapsulation
17 Why main() method is public, static and void in java
18 Explain about main() method in java
19 What is constructor in java
20 What is difference between length and length() method in java
21 What is ASCII Code
22 What is Unicode
23 Difference between Character Constant and String Constant in java
24 What are constants and how to create constants in java
25 Difference between ‘>>’ and ‘>>>’ operators in java
  1. what are static blocks and static initalizers in Java ?

    Static blocks or static initializers are used to initalize static fields in java. we declare static blocks when we want to intialize static fields in our class. Stati blocks gets executed exactly once when the class is loaded .Static blocks are executed even before the constructors are executed.

  2. How to call one constructor from the other constructor ?

    With in the same class if we want to call one constructor from other we use this() method. Based on the number of parameters we pass appropriate this() method is called.

    Restrictions for using this method :

    1. this must be the first statement in the constructor.
    2. we cannot use two this() methods in the constructor.
  3. What is method overriding in java ?

    If we have methods with same signature (same name, same signature, same return type) in super class and subclass then we say subclass method is overridden by superclass. When to use overriding in java If we want same method with different behaviour in superclass and subclass then we go for overriding. When we call overridden method with subclass reference subclass method is called hiding the superclass method.

  4. What is super keyword in java ?

    Variables and methods of super class can be overridden in subclass . In case of overriding , a subclass object call its own variables and methods. Subclass cannot access the variables and methods of superclass because the overridden variables or methods hides the methods and variables of super class. But still java provides a way to access super class members even if its members are overridden. Super is used to access superclass variables, methods, constructors.

    Super can be used in two forms :

    1. First form is for calling super class constructor.
    2. Second one is to call super class variables,methods.

    Super if present must be the first statement.

  5. Difference between method overloading and method overriding in java ?

Method Overloading Method Overriding
Method Overloading occurs with in the same class Method Overriding occurs between two classes superclass and subclass
Since it involves with only one class inheritance is not involved Since method overriding occurs between superclass and subclass inheritance is involved.
In overloading return type need not be the same In Overriding return type must be same
Parameters must be different when we do overloading Parameters must be same
Static polymorphism can be acheived using method overloading Dynamic polymorphism can be acheived using method overriding.
In overloading one method can't hide the another In overriding subclass method hides that of the superclass method

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published