6/1/25 -------- Q)Explain about Java primitive data types. =>byte,short,int and long are used to represent integral(non decimal) numbers. =>float and double data types are used to represent decimal numbers i.e. numbers with fractional part. =>To represent true/false values, we have "boolean" data type. =>To represent character data, we have "char" data type. Q)What is the output of the following application? class Output{ public static void main(String args[]){ float s=10.5; System.out.println(s); } } Ans:- This program causes compilatation error Reason. Any decimal literal (a constant value directly written in source code) is considered as "double type". But, in the above program we are trying to store it in float type variable. =>We can fix it as follows. double s=10.5; OR float s=10.5F; OR float s=10.5f; Q)What do you know about "char" data type in Java. =>variable of "char" data type occupies 2 bytes of memory (int C, it is only 1 byte). =>"char" data type supports unicode characters. =>Uni code characters promote i18n(internationalization) Operators ------------ Q)What is an operator? =>An operator is a symbol that acts upon data items known as operands in order to process them. For eg. 10+12 10 is an operand + is an operator 12 is an operand. Q)How are operators classified? =>Operators are classified based on two criteria. =>Based on the number of operands they are acting upon, operators are of three types. 1)unary operators(act upon only 1 operand) 2)binary operators(act upon 2 operands) 3)ternary operator(acts upon 3 operands) =>Based on the type of operation that they are perfroming on the operands, operators are classifed as follows. 1)arithmetic operators 2)assignment operators 3)relational/comparision operators 4)logical operators 5)bitwise operators 1 Q) 5/3=---------- Note:- int/int=int float/int=float int/float=float float/float=float 2 Q) 5%3=--------- Q)What are the similarities between "/" and "%"? =>Both are arithmetic operators =>Both perform division only =>Both are binary operators Q)What is the difference between "/" and "%"? =>"/" returns quotient after division. =>"%" returns remainder after division Q) What is the output of the following piece of code? int a=10; a++; System.out.println(a); Ans:- 11 Q)What is the output of the following piece of code? int a=10; a--; System.out.println(a); Ans:- 9 Q)What is the output of the following piece of code? int a=10; a +=3; System.out.println(a); Ans:- 13