Java For Loop and Types of For loops and For-each loop with the Examples

Java For Loop:The for statement is the most commonly used looping statement. The statement includes initialization an expression that specifies an initial value for an index, and the condition expression determines whether the loop is continued or not and the last iteration expression allows the index to be modified at the end of each pass.Types […]

Switch Statement in Java | Java Switch With Examples

Switch statement in Java: If several options are available then it isn’t recommended to take nested if-else we should go for switch statement so that readability of the code will be improved. “Switch” is a keyword, by using which we can create a selection statement with multiple choices. Multiple choices can be constructed by using […]

Java Polymorphism and Types of Polymorphism in Java with Examples.

Polymorphism in JavaWhat is Polymorphism in Java? Defining the multiple functions (or) methods with the same name associated with the same object is called as polymorphism. Types of polymorphism: There are two types of polymorphism. They are: 1) Static polymorphism (or) Compile time polymorphism. 2) Dynamic polymorphism (or) Run-time polymorphism. Static polymorphism (or) Compile time […]

Class and Object in Java with Programs and Examples

Class and objectsWhy do we need a class in Java?Java is an object-oriented programming language and represents data in the form of Objects. So in order to create an object, we required a class.What is a class?A class is user-defined data type in Java & is a Structure representing data and logic.(or)A class is a […]

Java Constructor | Types of Constructor in Java with Examples.

What is Constructor in Java?A constructor is a Functionality (or) method which is Executed automatically at the time of the creation of the Object. Why we require Constructor in Java?A constructor is required for creating and initializing Object in Java. Rules to define Constructor:1) Constructor name should be same as the Class name.2) A constructor […]

Java Print with examples and programs

Print in Java: The print() method prints the required output on the same line continuously again and again on the screen. The print is a method present in PrintStream Class present in There are 8 Print methods in PrintStream Class. They are:1) void print(Boolean b): Prints a Boolean value.2) void print(char c): Prints a […]

what is system.out.println in Java?

what is system.out.println in Java? System.out.println is a Java statement that prints the argument passed into the console which is generally standard output.In detail:1) A system is the name of the class in java.lang package.2) out is an object of print stream class and declared as static in System class. Present in java.lang package.3) println() […]

Java String Interview Questions and Answers

Java String Interview Questions and Answers 1) What is the difference between creating an object of string class using the new operator and using doubles quotes?A) Using double quotes object of the string class representing a specific sequence of characters could be created only once. Whereas using new operator we can create any number of […]

Java Exception Handling Interview Questions and Answers

Java Exception Handling Interview Questions 1) How many types of errors are there in Java? A) There are two types of errors are there in Java:1) Compilation error.2) Run-time error. 2) What is a compilation Error? A) Any error that occurs at the time of compilation could be called as Compilation Error. 3) What is […]