Looping Constructs in Java - While, Do While, Break and Continue

The while statement

The “while loop” is an alternative to “for loop”. a “for loop” is usually used when the number of times the block is to be executed is known. A “while loop” is usually used when the number of times the block is to be executed is not known, like prompting the user whether to stop executing during every iteration.

The syntax of “while loop” is:

while (<condition>) <statements>;


Access Modifiers in Java

Access modifiers are used to specify the accessibility or access levels of a type (class, interface) and its members (methods, variables and even constructors). There are three access modifiers and four access levels in Java. The three access modifiers are are private, protected and public. Four access levels (from most restricted to least restricted) are private, default (no modifier), protected and public. 

Introduction to Gradle lifecycle and Tasks

Gradle lifecycle

Gradle lifecycle consist of three phases: initialization, configuration, and execution:

  1. During Initialization, Gradle decides which projects are to participate in the build.

  2. During Configuration, task objects are assembled into an internal object model, usually called the DAG (for directed acyclic graph).

[Quiz] Important questions on JSP

  1. How can you call a JSP page using a request dispatcher?

  2. How can you suppress direct access to a JSP file through a client request?

[Quiz] Important Questions on Http and Servlets

  1. What are the three ways in which you can tell the container that your class is a servlet?

  2. Compare filters with RequestDispatcher mechanism.

  3. Can you include or forward to filters using the RequestDispatcher mechanism?

  4. What will happen if you call two RequestDispatcher forwards or includes from within a servlet's doXXX method?

  5. Can you use wrappers to have two RequestDispatcher forward requests without any exception?

Decision Control Constructs in Java

Decision control statements can change the execution flow of a program. 

Decision control statements in Java are:

  • if statement

  • Conditional operator

  • switch statement


Looping Constructs in Java - For and For-Each

Looping constructs in Java are:

  • For statement

  • For-each statement

  • While statement

  • Do while statement

We will see for and for-each here. We will see while, do while, break and continue statements in next note. 


The for statement

Syntax of for loop is:

Operator Plus(+) Overloading in Java

Java doesn't allow operator overloading yet + is overloaded for class String. Here we will discuss examples for use of + with Strings and characters.

Object Class - The Parent Class of All Classes in Java

There is a class in Java called Object and is present in the package java.lang.Object. This is different from the concept of objects in object oriented programing, and begenners may get confused. Note that is is just a class in Java with the name as Object. 


Object class API basics

  • Class java.lang.Object is the root of the class hierarchy in Java.

  • Every class has Object as a superclass either directly or indirectly.

Introduction to Strings in Java

A String is a sequence of characters (e.g. "Hello World").

A String is an object in java, and not a primitive. 


Creating Strings

We can create a String object in two ways:

  1. Assigning a String literal to a String variable

    • e.g. String greeting = "Hello world!";

    • Here, "Hello world!" is a string literal.


Search the Web

Custom Search

Searches whole web. Use the search in the right sidebar to search only within javajee.com!!!