Quizzes

[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?

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.

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>;

Example:

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).

[Example-Lab] Hands On Exercise and Quiz on Exceptions

Let us do a simple hands on excercise followed by some questions to understand exceptions better. For theory and concetps of exceptions in Java. you can refer to the note introduction-to-exceptions-in-java

 

Exercise

Create a class MyClass and create three methods myMethod1(), Method2() and Method3().

 

Invoke Method2() from Method1() and Method3() from Method2().

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.

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. 

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:

Introduction to Arrays in Java

Arrays are data structures that hold a group of elements and each element has a position denoted by an integer called the index of that element.  

 

Important properties of arrays

Important properties of arrays are:

  1. Array indexes (element positions) have to be integers and start at 0. 

Pages

Search the Web

Custom Search

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