Common programming questions asked in core java interview

Factorial Example: //CodeParent Presents Factorial Example public class FactCode { public static void main(String[] args) { int i, factout = 1; int factcode = 5; // The number to be calculated for factorial for (i = 1; i <= factcode; i++) { factout = factout * i; } System.out.println("Code Parent Presents Factorial Code !!!"); System.out.println("Factorial of " + factcode + " is: " + factout); } } Output: Code Parent Presents Factorial Code !!! Factorial of 5 is: 120 Fibonacci Example: //CodeParent presents Fibonacci Code…

Continue reading »

Tricky Core Java interview questions for 2 years’ experience

Sub classing: Sub classing is the creation of a new class that inheritance from an existing class in the class hierarchy. A subclass inherits state (in the form of data members) and behavior (in the form of methods) from the super class that are accessible to that subclass unless the subclass explicitly hides a member variable or overrides a method. State the members that are inherited by a class: The members that are inherited by a subclass are as follows, 1. Subclasses inherit super class…

Continue reading »

Core Java interview questions 1 -2 Years | Inheritance, Nested Class, Inner Class

Inheritance: Inheritance is the property of deriving a class from an existing class (called as base class) such that the derived class inherits all the characteristics of base class and it can also have its own properties. A derived class inherits the public, protected members of the base class. A derived class is usually larger than the base class, since it normally adds data members and member function in addition to what it inherits from the class. Single Inheritance: A derived class with only one…

Continue reading »