0% found this document useful (0 votes)
5 views

Print 1

Uploaded by

Ritam Saha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Print 1

Uploaded by

Ritam Saha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

1. What will be the output of the following program segments?

(i) String s = “application”; (iv) int a- 5, b = 2,c;


int p = s.indexOf(‘a’); if (a>b || a ! = b)
System.out.println(p); c = ++a+-b;
System.out.println(p+s); System.out.print(c+ ” “+a+” “+b);

(ii) String st = “PROGRAM”; (v) int i = 1;


System.out.println(st.indexOf(st.charAt( while(i++<=1)
4))); {
i++;
System.out.print(i + “”);
(iii) int a = 0;
if(a>0 && a<20) }
d++; System.out.print(i);
else a-;
System.out.println(a);

2. Arrange the operators in the order of higher precedence.


(1)++ (2)&& (3)>= (4)%

3. Attempt the following


i) Write a valid java program code to print the following array in matrix form with 2 rows and
2 columns.
int mat[ ][ ] = {{2,6},{10,20}};
ii) State the total size in bytes of the array a[4] of char data type and p[4] of float data type.

iii) String abc = “helloR”;


StringBuffer str = new StringBuffer(abc);
int num = str.capacity( );
what will variable num stores the value?
iv) StringBuffer s1 = new StringBufferC’Robot”);
String s2 = s1 .reverse( );
System.out.println(“s2 =” +s2);
System.out.println(“s1 =” +s1);

v) Write a java statement for finding and displaying the position of last space in string ‘str’.
vi) Which one of the following returns the corresponding primitive data type object from string object?
(i) Integer
(ii) readLine( )
(iii) valueOf( )
(iv) endsWith( )
vii) Find the output:
String a = “Sidharthissmartguy”, b= “MathsMarks”;
String h = a.substring(2,5);
String k = b.substring(8).toUpperCase( );
System.out.println(h);
System.out.println(k.equalslgnoreCase(h));
viii) Name a string function which removes the blank spaces provided in the prefix and suffix of a string.
ix) Name the keyword which will be used to resolve the conflict between method parameter and instance
variables/fields. Explain with example.

x) int y = 10 ; y+ = (++y * (y++ +5)); System.out.println(y);


What will be the output of the above code?

You might also like