Trending ▼   ResFinder  

ICSE Board Exam 2016 : Computer Science solved guide

10 pages, 0 questions, 0 questions with responses, 0 total responses,    0    0
Anshuman Bisoyi
De Paul School, Berhampur
+Fave Message
 Home > ansbsoy >

Formatting page ...

ICSE COMPUTER 2016 SECTION A 1. a) Encapsulation refers to the wrapping up of data (characteristics) and methods/functions (behaviour) that operate on the data into a single unit (called the class). Eg;- A class implements encapsulation with the help of access specifiers. b) Keywords are the words that convey a special meaning to the language compiler. These are reserved for special purpose and must not be used as normal identifier names. Eg:- abstract , while , extends c) Packages :1. java.io 2. java.lang 3. java.util d) i) Runtime error ii)Syntax error e) i)p=6 ii) q = 37 Working = 7+(10 *3) = 7 +30 2. a) == operator It checks for equality of primitive data types. It is a relational binary operator. equals() method It checks for equality of Strings objects. It is a static function of the String class of Lang package b) i)Explicit Type Conversion ii)implicit Type Conversion c) Formal Parameter:The parameters that appear at the function prototype and are a part of the function definition. E.g. :- void sum(int a,int b) // Formal Parameter Actual Parameter:The parameters that appear function call and are a part of the function call statement. Eg :- sum(a,b) // Actual Parameter d) public int PosChar(String str,char ch) e) public,private,protected ,default(any two) 3. a) i) 12 (Working :- (2+10)) ii) -2 The first two letters in the both the strings are identical The ASCII value of B is 66 The ASCII value of D is 68 So , 66-68 = -2 b) i)5.0 ii)4.0(bcoz return type is double) c) A parameterized constructor is a member function with the same name as that of the class and used to initialize instance variables by passing parametric values at the time of object creation. d) double T; T = Math.sqrt(((Math.pow(a,2)+((Math.pow(b,2))+((Math.pow(c,2))) Or Double T=Math.sqrt(A*A+B*B+C*C e) String str; str = ((x%2)==0)?"EVEN":"ODD" ; System.out.print(str); f) int m = 5 , n; for( n=10 ; n>=1 ; n-- ) { System.out.println(m*n); } g) Primitive data types :1. These are in-built datatypes. Java provides these datatypes. 2. The size of these datatypes are fixed. Eg:- byte,short,int,long,double,float,char,boolean Composite datatypes :1. These datatypes are made of / based on primitive datatypes. 2. The size of the datatypes are variable. As it depends on their constituent members. Eg:classes,arrays,interfaces h) i) Output 5 10 ii ) 3 times. Breaks on the third iteration i) a = 39 (7+7+9+8+8) j)i) boolean ii) Datatype returned is of type :String SECTION B 4. import java.util.*; class BookFair { String Bname; double price; public BookFair() { Bname = ""; price = 0.0D; } void Input() throws InputMismatchException { Scanner sc = new Scanner(System.in); System.out.println("Enter Book's name"); Bname = sc.nextLine(); System.out.println("Enter its price"); price = sc.nextDouble(); } void calculate() { double discount; if(price<=1000) { discount = 2d; } else if(price >1000 && price <=3000) { discount = 10d; } else { discount= 15.0d; } price= price- (discount*price)/100; } void display() { System.out.println("Name of book "+Bname); System.out.println("Price after discount "+price); } public static void main(String[] args)throws InputMismatchException { BookFair obj = new BookFair(); obj.Input(); obj.calculate(); obj.display(); }} 5. import java.util.*; class Menu { public static void main(String[] args)throws InputMismatchException { Scanner sc = new Scanner(System.in); int choice; System.out.println("Enter 1 to print Floyd's triangle "); System.out.println("Enter 2 to print ICSE pattern "); choice = sc.nextInt(); switch(choice) { case 1 : { int i,j;int a=1; for(i=1;i<=5;i++) { for (j = 0; j < i; j++) { System.out.print(a+" "); a++; } System.out.println(); } break; } case 2: { String str = "ICSE"; int i , j; for(i=0;i<4;i++) { for(j=0;j<=i;j++) { System.out.print(str.charAt(j)+" "); } System.out.println(); } break; } default: { System.out.println("Wrong choice !"); } } } } Or (I) k=0; for(int i=1;i<=5;i++) { for(j=1;j<=i;j++) System.out.print(++k+" "); System.out.println(); } ii) St="ICSE"; for(i=1;i<=4;i++) System.out.println(st.substring(0,i)); 6. int I,j,sp,pal,l; String st,st1; st=in.next(); l=st.length(); for(i=l-1;i>=0;i++) { st1+=st.charAt(i); } if(st1.equals(St)) pal=1; if(st.charAt(0)==st.charAt(l-1)) sp=1; if(pal==1) System.out.println("palindrome word "); if(pal!=1&&sp ==1) System.out.println(" special word only"); 7. import java.util.*; class Overload { void SumSeries(int n, double x) { int i; double s1=0.0; for(i=1;i<=n;i++) { if(i%2!=0) s1+=(x/i); else s1-=(x/i); } System.out.print("\nSum of Series = "+s1); } void SumSeries() { long s2=0L, p; int i, j; for(i=1;i<=20;i++) { p=1L; for(j=1;j<=i;j++) { p=p*j; } s2+=p; } System.out.print("\nSum of Series = "+s2); } public static void main() { Scanner sc=new Scanner(System.in); Overload obj=new Overload(); int n; double x; System.out.print("Series 1 : "); System.out.print("\nEnter the value of n : "); n=sc.nextInt(); System.out.print("\nEnter the value of x : "); x=sc.nextDouble(); obj.SumSeries(n,x); System.out.print("\nSeries 2 : "); obj.SumSeries(); } } 8. import java.util.*; public class Niven { public static void main() { Scanner sc = new Scanner (System.in); System.out.println(" Enter a number"); int num = sc.nextInt(); int n =num, sum = 0 ,digit = 0 ; while(n >0) { digit = n%10; sum = sum+digit; n=n/10; } if(num%sum ==0) sopl(" Niven number"); else sopl(" not a niven number"); } } 9. import java.io.*; // Package declared class wonders_locations_q9 { /** Start of the class **/ void main(String args[])throws IOException { /** Start of the main method **/ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); // Buffered Reader System.out.println(); String wonders [] = { "CHICHEN ITZA" , "CHRIST THE REDEEMER" , "TAJ MAHAL" , "GREAT WALL OF CHINA" , "MACHU PICCHU" , "PETRA" , "COLOSSEUM" }; /** Array storing the name of the seven wonders of the world **/ String locations [] = { "MEXICO" , "BRAZIL" , "INDIA" , "CHINA" , "PERU" , "JORDAN" , "ITALY" }; /** Array storing the locations of the seven wonders of the world **/ int i; String input; System.out.println(); System.out.println(" Enter the name of the place --> "); input = br.readLine(); // taking input for(i=0;i<7;i++) // for loop to check equality between input and location name { if(input.compareTo(locations[i])==0) // checking equality { System.out.println(locations[i] + " - " + wonders[i]); // displaying the location and wonder name side by side } else { System.out.println(" Sorry Not Found ! "); }} } /** End of the main method **/ } /** End of the class **/ All the answers are tested and practised ansbsoy

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

 

  Print intermediate debugging step

Show debugging info


 

 

© 2010 - 2025 ResPaper. Terms of ServiceContact Us Advertise with us

 

ansbsoy chat