Can We Override static Method in Java?

Can we override static method? is another important java interview question. Lets first take a look on what is method overriding. Method Overriding: When parent and child class have methods with same signature then it is called as method overriding. At run time compiler decides which method to call depending upon object type. Also Read: Can We Overload main Method in Java? Can We Override static Method in Java? No, we can’t override static method. Static method is not a part of object,

Read more

How to Change Tomcat Port Number?

Here you learn how to change tomcat port number. The default port number of tomcat is 8080. If the port number assigned to tomcat is used by any other application then you can’t run tomcat on that port. In that situation the only solution is to change tomcat default port number. There are two ways to achieve this that I have mentioned below. How to Change Tomcat Port Number?   Method 1: Tomcat Installation Directory 1. Go to conf folder

Read more

Can We Overload main Method in Java?

Here you will get answer for very basic question asked by beginners i.e. can we overload main method in Java? A function is overloaded in java by changing the number of arguments or their type. The main method can also be overloaded in the same way we overload any other method. How Can We Overload main Method in Java? Take below example.

Output String args[] In above program there are 3 overloaded main methods. If you will run the program it

Read more

Java Program to Insert Element in Array at Specified Position

Here you will get java program to insert element in array at specified position. How it works? First copy all the elements before the position where element is to be inserted in a new array. Now assign the element at given position in the new array. Finally copy all the elements after the position where element is to be inserted in a new array. We can partially copy elements of one array to another using System.arraycopy() method. Its syntax is

Read more

How to Send Email in Java Using SMTP?

Here you will learn how to send email in java using smtp. JavaMail API provides the functionality for sending email. The process involves following three step. Get Session Object Compose Message Send Message For sing JavaMail API we have to import jars mail.jar and activation.jar. Download the jars from below link and import in your project. Download: http://www.javatpoint.com/src/mail/mailactivation.zip Image Source Send Email in Java Using SMTP Example Below is the Java program to send email. Make sure to change the host

Read more

Java Program for Matrix Multiplication

Here you will get java program for matrix multiplication. Suppose we have matrix A with number of rows and columns as m and n. Let B be a matrix with number of rows and columns as p and q. Their multiplication is possible only if number of columns of matrix A is equal to number of rows of matrix B i.e. n should be equal to p. The resultant matrix is of order mxq. Also Read: Java Program for Matrix Addition

Read more

Servlet Login and Logout Using HttpSession Example

Here you will get servlet login and logout example using HttpSession. There are various ways to maintain session but here I will use HttpSession class. In this example we have a index.html page where a login form is displayed. When user enters login details and submits the form the request is sent to LoginServlet. If the details are correct then user is redirected to HomeServlet otherwise redirected to index.html. LogoutServlet invalidates the sessions to logout the user and redirect to index.html. If anyone tries

Read more

Servlet Registration Form with MySQL Database Example

Here you will get servlet registration form with mysql database example. This simple registration form include three fields, full name, email and password. If you want you can add more fields. Servlet Registration Form with MySQL Database Example MySQL Database As here we are using mysql database so create a database with name db. Now create a table with name user having three fields fname, email and pass of varchar type. Java Project Create a dynamic web project and add following

Read more
1 2 3 4 10