Download as rtf, pdf, or txt
Download as rtf, pdf, or txt
You are on page 1of 10

1.

2.

3.
4. 60

10+20+30

10+2030

102030

102030

3030

102030

5. a, c, d

6. 6 (arithmatic addition)

123 (string concatenation)

150 (ascii values of character 1,2,3 are 49,50,51)

1 2 3 (1st element is character and second element is string)

198 (ascii values of character A, B, C are 65, 66, 67)

ABC (string concatenation)

365 (ascii value of A is 65 and 65+100+200=365)


A B C (1st element is character and second element is string)

7.

8. import java.util.*;
class Example{
public static void main(String args[]){
Scanner input=new Scanner(System.in);
System.out.print("Input your age : ");
int age=input.nextInt();
System.out.println("Your current age is : "+age);
//--------------Do not modify before this line----
age = age + 10;
//---------------------Do not modify after this line---
System.out.println("Your age after 10 years is : " + age);
}
}

9.import java.util.*;
class Example{
public static void main(String args[]){
Scanner input=new Scanner(System.in);
System.out.print("Input number 1 : ");
int num1=input.nextInt();
System.out.print("Input number 2 : ");
int num2=input.nextInt();
System.out.println(num1+" "+num2);
//-----------Do not modify before this line--------
int a = num1;
num1 = num2;
num2 = a;
//------Do not modify after this line------------
System.out.println(num1+" "+num2);
}
}

10. a)

b) narrow conversion
narrow casting

c) wider conversion
wider casting

11. B, E

12. a, c, e

13. a, b

14. b

15. a, c, d

16. a, b, c, d

17. a, c, g

18. a. 3

b. -3

c. 3

d. -3
e. 3

f. -3

g. 3

19. a, b, c, d, e

20. a, c, d

21. a,b,c,d

22. a. 17

b. -10

c. -17

d. -3

e. 7

f. -3

23. -100

100

-100

-200

400

24. 100101

104

104
25. 101 100

102 101

103 102

26. 101 101

102 102

103 103

27. 100

100

100

101

102

103

28. a. 3

b. 0

c. 10

d. 0.0

e. 0.0

29. a. 30 //arithmatic addition

b.-10 // arithmatic adition

c. 31 (11 + 20) pre-incriment of a and then arithmatic adition

d. 30 (10+20) b increase after adding to a. post-incriment

e. 31 (11 + 20)
f.30 (10 + 20) a & b post incriment

g. 32 (11 + 21) a & b pre incriment

h. 31 (10 + 21) a post incriment & b pre incriment

30. 12 - 4*2 : 4

(12-4)*2 : 16

12 - (4*2) : 4

31. a. 6 // remainder of 7/10 is 7>> 7/2 is 3>> 3*2 is 6

b. 4 // 10/2 is 5>> remainder of 7/5 is 2>> 2*2 is 4

c. 1 // remainder of 7/10 is 7>> 2*2 is 4>> 7/4 is 1

d. 1 // 2*2 is 4>> 10/4 is 2>> remainder of 7/2 is 1

e. 7 // 10/2 is 5>> 5*2 is 10>> remainder of 7/10 is 7

32. a. 106

b. 12

c. 11

d. 44

33. a. 21

b. 22

c. 26

d. 27

e. 31

f. 33

g. 38

h. 42

You might also like