Gadgets

Wednesday, 27 July 2016

Basic responsive mobile menu

A simple basic responsive mobile menu


In this post, I explained how to create a basic responsive mobile menu using bootstrap and @mediaqueries.
Here it is for beginners to create a basic responsive mobile menu using bootstrap and @mediaqueries. I explained clearly with less coding, so I hope you can understand very easily by reading my post.






Tablet View



Sunday, 24 July 2016

Basic responsive webpage

A simple basic responsive webpage

In this post, I explained how to create a basic responsive webpage using HTML5, CSS and @media queries.
Here it is for beginners to create a basic responsive webpage using HTML5, CSS and @media queries. I explained clearly with less coding, so I hope you can understand very easily by reading my post.



Mobile View


Tablet View


Desktop View


Monday, 21 March 2016

Java web project using Servlet and JSP

Java Project using Servlet and JSP

In this article I explained a java project, it contains registration, login, update profile, change password, delete profile, logout, and forgot password operations.
I posted code here clearly and I drawn a flow chart for clear understanding.
Create the project in Netbeans
Create the Hibernate project in Netbeans

Saturday, 12 March 2016

Hibernate web application with CRUD operations using eclipse IDE

Hibernate CRUD operations in Eclipse

Here we have hibernate web application with CRUD operations using eclipse IDE and using Netbeans IDE 
Here I have created a registration form and servlet to insert data into database, and same as I done operations retrieve, update, and delete.
You need to follow the below steps to create hibernate application:
1.      Create the Dynamic web project
2.      Load the required jar files
3.      Create the persistent class
4.      Create the mapping file for persistent class
5.      Create the configuration file
6.      Create the classes that store, retrieve, update, and delete.
7.      Run the application

It is very simple to understand, don’t feel like it is hard and programs are so long.

Read also: 

Wednesday, 9 March 2016

java program for super keyword

Write a java program to given the example for “super” keyword.


super() is used to invoke super class constructors and super keyword is refer super class members.
in this program i did show the difference with and without super keyword.
by using super keyword we can access parent class properties.

public class SuperTest {
       int number=10;
       SuperTest(){
        System.out.println("parent class constructor ");
       }     
}
class Test extends SuperTest{    
       int number=20;      
       Test(){
              super();
              System.out.println("using super keyword :" +super.number);
              System.out.println("with out using super keyword :" +number);
       }     
       public static void main(String[] args) {
              Test obj=new Test();      
       }
}

OUTPUT:

/*
parent class constructor
using super keyword :10
with out using super keyword :20
*/

Tuesday, 8 March 2016

java program for static variables, methods, and blocks.

Write a java program to demonstrate static variables, methods, and blocks.

We can access static variables, blocks, and methods without creating object as shown in the below program.
JVM first check for the main method and after checking the main method it will execute static block after that execute remaining code.
public class StaticTest {
       static int id=1214; 
       static{
              String name="narendar";
              System.out.println("static block "+name);
       }
       static void display(){
              String group="CSIT";
              System.out.println("static method "+group);
       }     
       public static void main(String[] args) {
              System.out.println("static variable "+id);
              display();          
       }
}

Output:

/*
static block narendar
static variable 1214
static method CSIT

*/

java program for exception handling mechanism

 Write a java program that describes the exception handling mechanism.

To handle exception we use try, catch, finally block. In try block we write risky code. If any exception will occur in try block, that exception handle in catch block. Try block will execute if exception is occur or not.
In this program we will get ArithmeticException in try block, we are handling that exception in catch block.
We will get output catch-finally block instead of try block.
public class ExceptionTest {
       public static void main(String[] args)
       {
              try
              {
                     int a=10;
                     int b=0;
                     int c=a/b;
                     System.out.println(c);
              }
              catch(ArithmeticException ae)
              {
                     System.out.println(10);                 
              }
              finally
              {
                     System.out.println("finally");
              }            
       }
}

OUTPUT:

/*
10
Finally
*/

Example for command line arguments

Write a java program give example for command line arguments.

public class CammandTest {
       public static void main(String[] args) {
              System.out.println(args[0]);
              System.out.println(args[1]);
              System.out.println(args[0]+args[1]);
       }
}

OUTPUT:

/* D:\Java>java CammandTest javathub blogspot
javathub
blogspot
javathubblogspot*/

Monday, 7 March 2016

Default values of all primitive data types

Write a java program to display default value of all primitive data types of java.

Default Values of all primitive data types:


Data Type
Default Value
byte
0
short
0
int
0
long
0L
float
0.0f
double
0.0d
char
‘u0000’
String
null
boolean
false

public class DefaultValue {
       byte b;
       short s;
       int i;
       long l;
       float f;
       double d;
       char ch;
       String str;
       boolean flag;      
       public static void main(String[] args) {             
              DefaultValue dv=new DefaultValue();
              System.out.println("byte value : " +dv.b);
              System.out.println("short value : " +dv.s);
              System.out.println("int value : " +dv.i);
              System.out.println("long value : " +dv.l);
              System.out.println("float value : " +dv.f);
              System.out.println("double value : " +dv.d);
              System.out.println("char value : " +dv.ch);
              System.out.println("String value : " +dv.str);
              System.out.println("boolean value : " +dv.flag);
       }
}

OUTPUT:

byte value : 0
short value : 0
int value : 0
long value : 0
float value : 0.0
double value : 0.0
char value :
String value : null
boolean value : false
we get blank space for char data type