Example HTML page

Java Assignment2

Hi, Please do the following assignment regarding to java programs.

1.Solve the following  java program

a.Declare a variable known as ‘num’ of integer datatype and multiply that ‘num’ by 2 and print the result in integer type.

b.Consider character variable and to display the equivalent character ASCII code for ‘S’.

2.What is the area of rectangle if length and width are 5.7 & 3.2 respectively.

3.Check whether the number 7 is prime or not using if-else statement.

4.Display the values in the console device from 1 t0 10 using for loop statement..

5.Display the values in the console device from 10 to 1 using while loop and do while loop.

6. Consider the 2 variables num1=100 , num2=20 . Apply all the arithmetic operators and display the result of following.

num1 + num2

num1 num2

num1 * num2

num1 / num2

num1 % num2

7.Declare the variable var=6 then what will be the result of following

a.var++

b.++var

c.var–

d.–var

8.Consider the variables a=10,b=20 then display the result of Boolean values for

a.(a == b)

b.(a != b)

c.(a > b)

d.(a < b)

e.(b >= a)

f.(b <= a)

9. Consider the ternary operator and let us assume that the month ‘February’ has ’29’ days. Then display the result as ‘Not a leap year’.

10. a.Declare the integer variable and assign its value as 60 and you should display the same integer value interms of float and double types. (hint:  use implicit type casting concept)

b.Consider the floating value 31.4 and display the output as integer value.( hint:use explicit type casting)

Example HTML page

Leave a Reply

Your email address will not be published. Required fields are marked *

Pin It on Pinterest