Marking Literals and Its Type in a program – Computer Sir Ki Class


Solved Problem!#JAVA#3828    siteicon   siteicon  

Problem Statement - Marking Literals and Its Type in a program

Write down all the literals in the given program and tell its type of literal.

TC++ #3828

class SP_Literals
public static void main(String[] args)
int a=101;
double b=3.21;
char c='u0061';
System.out.println("You are "+c+" smart programmer = "+true);

Test it !


Run Output

You are a smart programmer = true

101  – Integer Literal
3.21 – decimal/fractional/real literal
45.345f – decimal/fractional/real literal
u0061 – Character Literal

You are  – String Literal
smart programmer – String Literal
true – Boolean Literal

Common Errors

  • Student often forget that a boolean literal can be a part of println() method argument also.


sunmitra| Created: 13-Mar-2018 | Updated: 13-Mar-2018|