Important Question of Computer Chapter- 1

what is java


1. Object. An object is a an instance of a class. For example, Lenovo 6000 is an instance of cellphone,Maruti is an instance of the class car. An object has its own identity. Even if two objects have same attributes( structure,name,size) till they are distinct. 

2. Class- A class represents a group of objects of the same kinds. For example,      class of cellphone represents Moto G plus 4G,Nexus 5X,Sony Xperia X,Samsung Galaxy On 7,etc. Class of cars represents-Maruti, Honda,Opel,Ford, etc. Objects having the same attributes(structure,name and size ) and behaviour (operations)are grouped into a class. 

It wraps up all the information( attributes and functions)needed for its objects in one unit. It thus, leads to information hiding or data abstraction.

3. Characteristics of objects. Each object has the following characteristic:
. Unique identity 
. State (which may change)
. Behavior 

4. An class as an object factory: Each class describes possibly an infinite set of individual objects. So, it can be called a factory of objects. e.g., a class of cellphone can have numerous objects as Nokia, Samsung, Panasonic, etc. The features and functions of the objects are described within the class.

5. Identity of an object: An object has its own identity. It means that two objects are distinct even if they have the same attributes(structure, name, and size). e.g, two Maruti's are physically distinct though they are the same objects, i.e., Maruti.

6. Java virtual machine  (JVM): An interpreter that converts byte code to machine language code.

7. Byte code: It is an intermediate code that is produced by a Java compiler and is ready to be executed by JVM. It is a machine-independent code. It is further translated by a java virtual machine interpreter to a machine-executable format.




8. Unicode. It is an international standard by which each number, letter, digit, or symbol is given a unique number that is valid across different platforms and programs. This is based on the fundamental fact that computers just deal with numbers. They store letters and other characters by assigning a number for each. Unicode characters take 2 Bytes.

9. Token- The smallest unit that combines to make a program is known as tokens. Many tokens together make the program complete and correct.

10. Keywords- The reserved words of java have a special meaning for them. Java has 48 used keywords.

11. Identifiers- The names of variables, classes, objects, functions(or method ), arrays, which are given by the programmer are called identifiers.

12. Operators- Operators are the symbols that perform operators on operands and yield a result. For details refer to chapter 4- Operators in Java.

what is java



13. Literals. A constant value is called a literal. It gives the exact representation of the data. For example 29.7, 'p', "Pincode".
                       (Types of literals)

String, floating, boolean, character,                           integer,
      |
Decimal, octal, hexadecimal 

14. Punctuators. The punctuation marks used in Java are Punctuators. {,}, {,},",', . , [,],,, . etc.


15. Data types. Data types are the keywords provided by java to declare the kind of data that a variable will store and the operations to deal with them in the program.

Data types are divided into two groups:

.Primitive data types - includes byte, short, int, long, float, double, boolean, and char.
  
.Non-primitive data types - such as String, Arrays, and Classes (you will learn more about these in a later chapter)

16. Primitive data types. These are the basic data types that are independent of any other data type. They are pre-defined or built-in types of java.

17. Non-primitive data types. Reference data types that are directly or indirectly dependent on primitive data types are known as non-primitive data types. 
 
18. Types of variables: In the Java program, various categories of variables are used they are shown below:
                     ( Types of variables )
  • Global variable
  • Local variable 
  • Static variable 
  • Instant variable

19. Typecasting. The process of converting one data type to another data type is called typecasting.
     • implicit type casting 
     • explicit type casting 

20. Implicit typecasting. When one type of value is assigned to another type of variable, the data type is converted automatically, if the two are compatible data types or suppose one variable value is of lower data type another one is a higher data type, then java follows the promotion rule. Variable of lower data type is converted to a value of higher data types. 
For example int a1 =309, b=209;long c,d,e;
           c=a1+b;         //607
           d=a1-b;           //11
            e=a1*b;     //92082

20. Explicit typecasting. Forcefully converting one data type to another data type is called explicit typecasting. 
 General format:(required         datatype)variable;      
 For example int a1=3;
 byte k=(byte)a1;                 //3

21. Operator. An operator is a symbol that acts/operate on the operands and yields the required results. 

22. Unary operators. Increment operators(++) and Decrement Operators  (--)are the arithmetic operators which are Unary in nature as they take only one operand. Not logical operator (!)is also a Unary operator. 

23. Binary operators. All relational operators are binary operators. All arithmetic operators expect increment and decrement operators are binary operators. All logical operators expect NOT are binary operators. 

24. String. A 'string' is a term that refers to a set of characters. Java provides a class String in Java. lang package whose objects can be treated as variables of String type.  

25. Types of errors. The three types of errors that are mostly encountered during programming are syntax error, runtime error, and logical error.

26. Packages. Classes are grouped together to make a package. The classes contained in packages can be reused in other programs without physically copying them into the program.