Pratishtha
| Subject: Doubts Thu Jan 31, 2008 1:53 pm | |
| Question 1
A. Write a program to input two strings consist of maximum 80 characters. Examine both the strings and remove all the common characters from both of these strings. Display the resultant string.
B. Write a function to suppress negative elements of an array to bottom without altering
the original sequence i.e. if array contains 5 , -4 , 3 , -2 , 6 , -11 , 12 , -8 , 9
Then the return array will be : 5 , 3 , 6, 12 , 9 , -4 , -2 , -11 , -8
Question 2
A. What are input and output streams? What is the significance of DataOutputStream class.
B. Describe the various classes available for character oriented file operation.
|
|
abhas Active member
| Subject: JAVA icse class x bluej Thu Jan 31, 2008 3:25 pm | |
| ans.1(a)
//Write a program to input two strings consist of maximum 80 characters. Examine both the strings and remove all the common characters from both of these strings. Display the resultant string.
class srt { void main(String a,String b) {
if(a.length()>80 || b.length() > 80) { System.out.println("Program will exit as length of String is greater than 80 characters"); System.out.println("NOTE:Space is also counted as Single character"); System.exit(0); }
int y=0; String x=""; int A=a.length(); for (int c=0;c
Last edited by on Fri Feb 01, 2008 3:10 pm; edited 1 time in total |
|
abhas Active member
| Subject: Re: Doubts Thu Jan 31, 2008 3:34 pm | |
| ans 2(a) inputstrems areused to take input through standard input device (keyboard) and outputstreams are used to display output on standard output device(monitor) DataOutputStream is a class derived from FilterOutputStream class that allows you to write binary represented data of Java primitive data types reading from an underlying output stream in a machine-independent way. [It is used to perform output] |
|
abhas Active member
| Subject: Re: Doubts Thu Jan 31, 2008 3:36 pm | |
| i think ques 2(b) is not in course if u know the ans then plz. explain .... |
|
abhas Active member
| Subject: ICSE JAVA PROGRAMS Thu Jan 31, 2008 4:00 pm | |
| ans1(b) //i tried and made this but it is changing seq. of negative nos. //I think to do that we must know the no. of negative nos. //Dont worry i'll try it once again properly tonight //And may be give u the correct ans. tomorrow //Bye.... //Yes i must say all ur ques. were really cool !!!!!! //Now i must sleep for atleast 1 hr as i m really tired
class arrange { void main(int arr[]) { int l=arr.length; int x=l-1;//arr.length-1 int y=0; int b[]=new int[l]; int c; System.out.println("ORIGINAL"); for(c=0;c<l;c++) System.out.println(arr[c]); System.out.println(" "); for (int a=0;a<l;a++) { if(arr[a]<0) { b[x]=arr[a]; x--; } else { b[y]=arr[a]; y++; } } System.out.println("new value to be returned"); for(c=0;c<l;c++) System.out.println(b[c]); } } |
|
abhas Active member
| Subject: Re: Doubts Fri Feb 01, 2008 3:12 pm | |
| //yes i did that one as well //it was very very easy class sort { void main(int arr[]) { int l=arr.length; int b[]=new int[l]; int a[]=new int[l]; int x,z=0,y=0; System.out.println("array :"); for(x=0;x<l;x++) System.out.println(arr[x]); System.out.println(""); for(x=0;x<l;x++) { if(arr[x]<0) { b[y]=arr[x]; y++; } else { a[z]=arr[x]; z++; } } for(x=0;x<z;x++) arr[x]=a[x]; int d=0; for(x=z;x<l;x++) {arr[x]=b[d];d++;} System.out.println("New array to be returned"); for(x=0;x<l;x++) System.out.println(arr[x]); } } |
|