Tokens in C++.

Q1. Explain tokens in C++. Also discuss their role and importance.

Ans. The smallest individual unit in a program is known as a token.

C++ has the following tokens:

  1. Keywords
  2. Identifiers
  3. Literals
  4. Punctuators
  5. Operators


  1. Keywords

Keywords are the words that convey a special meaning to the language compiler. These are reserved for special purpose and must not be used as normal identifier names.

For example:

break, delete, if, goto, int, char, etc.

  1. Identifiers

Identifiers are fundamental building blocks of a program and are used as the general terminology for the names given to different parts of the program through variables, objects, classes, functions, arrays etc.

For example:

Myfile, MYFILE, _CHGK, DATE_7_73,etc.


Identifier forming rule of C++ states the following:

An identifier is an arbitrarily long sequence of letters and digits. The first character must be a letter; the underscore (_) counts as a letter. Upper and lower-case letters are different. All characters are significant.


  1. Literals

Literals (often referred to as constants) are data items that never change their value during a program run.

C++ allows three types of literals:

  • Integer Constant
  • Character Constant
  • Floating Constant
  • String Literal

For example:

1234, ‘t’, 2.0, “rty”, etc. Read More …

Java Netbeans GUI application that demonstrate arithmetic operators.

Q7. Design a Java Netbeans GUI application that gives demonstration of all arithmetic operators.


Create a GUI application as per following screenshot.


Double click BtnAdd button boundary and type the following code, below the line that says, ‘// TODO add your handling code here’


int n1,n2,a; Read More …