Basics of C Programming

Tokens

In a C language, token is either a keyword, a symbol ,an identifier, a constant or a string literal.

A C program consists of various tokens for example, the following C program consists of five tokens −

The individual tokens are −

Comments

Comments are the text in C program and they are ignored by the compiler during compilation and execution.

They start with /* and terminate with the characters */ as shown below −

Anything written within Comment will never execute. You can’t write comments within comments.

Identifiers

In a C language, identifier is a name given to any variable, function, or any other user-defined item.

C language identifier starts with a letter A to Z, a to z, digits (0 to 9) or an underscore ‘_’ followed by zero.

C does not allow punctuation characters such as @, $, and % within identifiers. Here are some examples of acceptable identifiers −

Keywords

In a C language keywords are the reserved words whose meaning already explained in a compiler.

These reserved words can’t be used as a variables or identifier names. There are 32 Keywords in C

auto else long switch
break enum register typedef
case extern return union
char float short unsigned
const for signed void
continue goto sizeof volatile
default if static while
do int struct double

Super Keyword in Java

Whenever a sub class wants to refer its immediate super class it can do so by using of super.

Use of super keyword

  • Super calls the super class constructor
  • It solves the problem of name hiding.
  • Using super keyword we can access super class overridden method

Super calls the super class constructor

In java programming, when a super class and sub class both has a constructor  than super class constructor will not call.

We can call such constructor by using super keyword.

Super call the immediate super class constructor.

Note: Call to super class constructor must appears as the first statement with in the sub class.

Description:  When super(i,j); ” line will execute. “ super( i, j ) “ will call it’s immediate super class  A’s constructor. 

Solves the problem of name hiding using super

In java programming, when a super class and sub class both has a instance variable that has a same name then in the sub class,  instance variable of sub class hides it’s super class instance variable. This problem is known as name hiding problem.

We can solve the problem of name hiding by using super keyword.

Description: Superclass A and subclass B both have a variable i, then in the subclass B variable, i of the superclass cannot be accessed directly.

Subclass variable i hides its superclass variable i. Using “super.i” we can access the hidden variable i of super class A in subclass B.

Using super keyword we can access super class overridden method

In Java programming, when a super class and sub class both has a method that has Superclass same name and type signature than subclass method overrides its superclass method.

Such methods are called overridden method subclass and this process is said to be method overriding.

If we want to access the superclass overridden method, we can do so by using super keyword.

Description:  When  lineB.show(); “  will execute it will call sub class show().

Method show() of super class will overrides. Class A’s show() will never execute. But we can call super class show() method by using super keyword.

Here “ super.show();” will calls super class A’s overridden method.

Java Keywords

Java contains 53 reserved words out of which 50 are keywords out of 50 only 48 keywords are used and two keywords const and goto are not in use and 3 are literals values true, false and null.

These reserved words can not be used as identifiers.

java reserved words hierarchy
java reserved words hierarchy

Java Keywords:   keyword is a reserved word that has a predefined meaning in the language, therefore, we cannot use keywords as names as a  class, methods, variable name or as any other identifier. Keywords of java are:

abstractcontinuefornewswitch
assertdefaultgotopackagesynchronized
booleandoifprivatethis
breakdoubleimplementsprotectedthrow
byteelseimportpublicthrows
caseenuminstanceofreturntransient
catchextendsintshorttry
charfinalinterfacestaticvoid
classfinallylongstrictfpvolatile
constfloatnativesuperwhile

const and goto are not in use
strictfp added in jdk 1.2
enum added in jdk 1.5

Reference

  1. Java Language Keywords
  2. List of Java keywords