Java Data Types

Java Basic Data Types

1.What is a unicode system?

A: Unicode system is an encoading standard that provides a unique number for every character,no matter what the platform ,program,or language is.Unicode uses 2 bytes to represent a single character.

2.How many data types are available in java?

A:There are two data types available in Java:
     Primitive Data Types
     Reference/Object Data Types

3.What are the primitive types in java?

A:In Java, every variable has a type declared in the source code. There are two kinds of types: reference types and primitive types. Reference types are references to objects. Primitive types directly contain values. There are 8 primitive types:


4.What is the difference between float and double?

A: Float can represent up to 7 digits accurately after decimal point,Where as double can represent up to 15 digits accurately after point.

5.Why is the size of character 1 byte in 'c' language and 2 bytes in java language?

A:In 'c' language the application can be devloped following only english language.To store the characters of english language 1 byte of memory is sufficient.C language follows ASCII  character set.
   In Java language the application can be developed by using multiple forign languages to store the characters of memory is not sufficient .So the size of character is increased to 2 bytes.The java language follows UNICODE character set.

6.What is boolean category ? Why we are using this one?

A:The boolean category contains only one data type and it is boolean.The boolean data type can be used for storing only two values they are "true" and "false".

7.What is a variable and variable declaration in java?

A:The variable represents a name given to a memory location which can be used for storing the data required in a program.
     Variable declaration means it is a process of specifying what type of data will be stored in to the memory location.

  Ex:int rollno;
      char gender;
      double marks;

8.Are arrays primitive data types?

A:In Java, Arrays are objects.

9.What are the literals?How many types of literals are available in java?

A:A literal represents a value that is stored into a variable directly in the program.

  Ex:boolean result=false;
       char gender='m';
         short s=1000;
In the above statement ,the right hand side values are called literals,Because these valuues are being stored into the variables shown at the left hand side.So we have  different types of literals.these are
1.Integer literals
2.Float literals
3.Character literals
4.String literals
5.Boolean literals

10.What is the difference between Integer literals and Float literals?

A:  Integer literals represents the fixed integer values like 100,-55,12353,etc...All these numbers belong to decimal systems,which uses 10 digits from 0 to 9 to represent any number.
      Float literals represent fractional numbers.These are the numbers with decimal points like 2.0,0.005,2.78,-8.5 etc..Which should be used with float or double type variables.

11.What are the character literals?

A:Character literals indicate the following
i.General characters,like A,b,6 etc..
ii.special characters like ?,@,etc..
iii.unicode characters,like\u0042
iv.Escape sequence(backslash codes)like \n,\b,etc..

12.What is identifier?

Any name that is used for the purpose of identifiction is called identifier.

  Eg:variable name,method name,class name etc..

13.what are the rules for writing an identifier?

A:i.An identifier means must be combination of digits,underscore.
ii.An identifier name must not be begin with a digit. cannot contain spaces.
iv.Their is no restrictions on the identifiction length.But it is recommended to write an identifier using not more than 16 characters.
v.It is recommended to provide the identifier names apporoximately acording to the application requirements.

14.What is conventions?Why we are using conventions?
A: The predefiend java code will follow the java coding conventions and as a programer we are also recommended to follow the coding conventions.
    It is always a best practise to follow the coading convetions while developing the applications.

15.What are the Conventions for Class name?

 A: Class names always begin with a capital letter (eg. java.util.Scanner). And if there are mutiple words in the class name then each word must also begin with a capital letter (eg. java.util.GregorianCalendar). Also package names always start with lowercase characters (util, lang, io, etc). And if there are multiple words in the package name, then you need to use uppercase for all words except for the starting word. This naming method is popularly called as UpperCamelCase which is a type of CamelCase! Interfaces also use same convention.


16.What are the Conventions for Objects/Variables:

A:Java Naming convention specifies that instances and other variables must start with lowercase and if there are multiple words in the name, then you need to use Uppercase for starting letters for the words except for the starting word.


Post a Comment