Search Tutorials

Top JWT(JSON Web Token) Interview Questions | JavaInUse


Top JWT(JSON Web Token) frequently asked interview questions.

In this post we will look at JWT(JSON Web Token) Interview questions. Examples are provided with explanations.


Q: What is need for JWT?

A :
  • JWT stands for JSON Web Token
  • It is pronounced as JAWT
  • It is Open Standard - RFC7519
  • JWT makes it possible to communicate securely between two bodies
  • JWT is used for Authorization

Understanding the need for JSON Web Token(JWT)

Q: What are the advantages of JWT?

A :

Advantages of JWT Authorization



  • JWT is self contained. It is a value token. So during each validation the Gmail server does not needs to fetch the information corresponding to it.
  • It is digitally signed so if any one modifies it the server will know about it
  • It is most suitable for Microservices Architecture
  • It has other advantages like specifying the expiration time.

Q: What is the structure of JWT?

A : A JWT consists of 3 parts -

  • Header
  • Payload
  • Signature

Q: What is expiration date of JWT?

A : Expiration Time - This the time for which we want the generated JWT to be valid for. This will be in milliseconds. Suppose we want the JWT to be valid for 5 hours, then we will specify this value as 18000000

Q: How do we specify expiration date of JWT?

A :
	private String doGenerateToken(Map<String, Object> claims, String subject) {

		return Jwts.builder().setClaims(claims).setSubject(subject).setIssuedAt(new Date(System.currentTimeMillis()))
				.setExpiration(new Date(System.currentTimeMillis() + jwtExpirationInMs)).signWith(SignatureAlgorithm.HS512, secret).compact();
	}

See Also

Spring Boot Interview Questions Apache Camel Interview Questions Drools Interview Questions Java 8 Interview Questions Enterprise Service Bus- ESB Interview Questions. JBoss Fuse Interview Questions Angular 2 Interview Questions