Computer Applications Answer Key Class IX December 2017

Similar documents
ICSE 2015 COMPUTER APPLICATIONS. Md. Zeeshan Akhtar

ICSE Class 10 Computer Applications ( Java ) 2010 Solved Question...

COMPUTER APPLICATIONS

In this chapter, you will:

PROGRAMMING FUNDAMENTALS

ICSE Solved Paper, 2018

Review for Test 1 (Chapter 1-5)

Term 1 Unit 1 Week 1 Worksheet: Output Solution

Computational Expression

Midterm Examination (MTA)

e) Implicit and Explicit Type Conversion Pg 328 j) Types of errors Pg 371

Oct Decision Structures cont d

C212 Early Evaluation Exam Mon Feb Name: Please provide brief (common sense) justifications with your answers below.

(c) ((!(a && b)) == (!a!b)) TRUE / FALSE. (f) ((!(a b)) == (!a &&!b)) TRUE / FALSE. (g) (!(!a) && (c-d > 0) && (b!b))

ESC101 : Fundamental of Computing


ECE 122. Engineering Problem Solving with Java

Assignment2013 Please use this document only for verifying if your programs are right. Do not blindly copy paste and waste your time.

Write a program which converts all lowercase letter in a sentence to uppercase.

ASSIGNMENT CLASS-11 COMPUTER SCIENCE [C++]

I SEMESTER EXAM : : XI :COMPUTER SCIENCE : MAX MARK a) What is the difference between Hardware and Software? Give one example for each.

The Hyderabad Public School Begumpet, Hyderabad, A.P.

Outline. Overview. Control statements. Classes and methods. history and advantage how to: program, compile and execute 8 data types 3 types of errors

B.V. Patel Institute of BMC & IT, UTU 2014

Programming: Java. Chapter Objectives. Chapter Objectives (continued) Program Design Including Data Structures. Chapter 7: User-Defined Methods

Chapter 1: Introduction to Computers, Programs, and Java

Object Oriented Pragramming (22316)

Computer Programming, I. Laboratory Manual. Experiment #6. Loops

Java Basic Programming Constructs

ICSE Class 10 Computer Applications ( Java ) 2014 Solved Question Paper

Introduction to Computer Science Unit 2. Notes

Java Programs. System.out.println("Dollar to rupee converion,enter dollar:");

Programming with Java

Mathematical Functions, Characters, and Strings. CSE 114, Computer Science 1 Stony Brook University

CS 177 Spring 2010 Exam I

Good Earth School Naduveerapattu. Computer Applications Worksheet Class X

Java Identifiers, Data Types & Variables

CSc Introduction to Computing

CS212 Midterm. 1. Read the following code fragments and answer the questions.

CS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University

Chapter 7 User-Defined Methods. Chapter Objectives

Computer Programming, I. Laboratory Manual. Final Exam Solution

COMP 250: Java Programming I. Carlos G. Oliver, Jérôme Waldispühl January 17-18, 2018 Slides adapted from M. Blanchette

K E Y I CYCLIC, EXAMINATION SECTION A

To define methods, invoke methods, and pass arguments to a method ( ). To develop reusable code that is modular, easy-toread, easy-to-debug,

Computer Programming, I. Laboratory Manual. Experiment #4. Mathematical Functions & Characters

COE 212 Engineering Programming. Welcome to Exam II Tuesday November 28, 2018

Mathematical Functions, Characters, and Strings. CSE 114, Computer Science 1 Stony Brook University

CIS 1068 Program Design and Abstraction Spring2016 Midterm Exam 1. Name SOLUTION

Date: Dr. Essam Halim

AP CS Unit 3: Control Structures Notes

Exam 2. Programming I (CPCS 202) Instructor: M. G. Abbas Malik. Total Marks: 40 Obtained Marks:

Ch. 6. User-Defined Methods

Sri Vidya College of Engineering & Technology

Chapter 4 Mathematical Functions, Characters, and Strings

Problems with simple variables

Expressions & Flow Control

data_type variable_name = value; Here value is optional because in java, you can declare the variable first and then later assign the value to it.

1 Epic Test Review 2 Epic Test Review 3 Epic Test Review 4. Epic Test Review 5 Epic Test Review 6 Epic Test Review 7 Epic Test Review 8

3. Convert 2E from hexadecimal to decimal. 4. Convert from binary to hexadecimal

Operators in java Operator operands.

COMP-202B - Introduction to Computing I (Winter 2011) - All Sections Example Questions for In-Class Quiz

Output :: /* display results */ System.out.print( Call Duration: );

Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub

Java Programming. MSc Induction Tutorials Stefan Stafrace PhD Student Department of Computing

Java Foundations: Introduction to Program Design & Data Structures, 4e John Lewis, Peter DePasquale, Joseph Chase Test Bank: Chapter 2

Chapter 5 Methods. Modifier returnvaluetype methodname(list of parameters) { // method body; }

DM550 / DM857 Introduction to Programming. Peter Schneider-Kamp

Chapter 3: Operators, Expressions and Type Conversion

The high-level language has a series of primitive (builtin) types that we use to signify what s in the memory

Introduction to Programming Using Java (98-388)

Introduction to Computer Science Unit 2. Notes

Module 4: Characters, Strings, and Mathematical Functions

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups:

Problem Grade Total

Getting started with Java

COMPUTER APPLICATIONS

Java Applets. Last Time. Java Applets. Java Applets. First Java Applet. Java Applets. v We created our first Java application

The Sun s Java Certification and its Possible Role in the Joint Teaching Material

Full file at

COMPUTER APPLICATIONS

! Widely available. ! Widely used. ! Variety of automatic checks for mistakes in programs. ! Embraces full set of modern abstractions. Caveat.

COE 211/COE 212 Computer/Engineering Programming. Welcome to Exam II Thursday December 20, 2012

COE 212 Engineering Programming. Welcome to Exam II Thursday April 21, Instructors: Dr. Salim Haddad Dr. Joe Tekli Dr. Wissam F.

Strings. Strings and their methods. Dr. Siobhán Drohan. Produced by: Department of Computing and Mathematics

COMPUTER APPLICATIONS

Getting started with Java

1. Find the output of following java program. class MainClass { public static void main (String arg[])

JAVA MOCK TEST JAVA MOCK TEST II

CONTENTS: Compilation Data and Expressions COMP 202. More on Chapter 2

String is one of mostly used Object in Java. And this is the reason why String has unique handling in Java(String Pool). The String class represents

Some Sample AP Computer Science A Questions - Solutions

Selected Questions from by Nageshwara Rao

Functions. Arash Rafiey. September 26, 2017

M1-R4: Programing and Problem Solving using C (JAN 2019)

Java Simple Data Types

Computer Programming, I. Laboratory Manual. Experiment #7. Methods

Chapters 1-4 Summary. Syntax - Java or C? Syntax - Java or C?

Computer Programming C++ (wg) CCOs

SOFTWARE DEVELOPMENT 1. Control Structures 2018W A. Ferscha (Institute of Pervasive Computing, JKU Linz)

Transcription:

Computer Applications Answer Key Class IX December 2017 Question 1. a) What are the default values of the primitive data type int and float? Ans : int = 0 and float 0.0f; b) Name any two OOP s principle. Ans : Abstraction, Encapsulation, polymorphism, class, object and inheritance c) What are identifiers? Identifiers are the user defined name for the various parts of the program d) Identify the literals listed below: i) 0.5 floating point ii) A character iii) false Boolean iv) a String e) Define the term bytecode. Bytecode is the compiled code that can be interpreted by JVM. Question 2. a) Evaluate the value of n if value of p=5, q=19 int n= (q-p)>(p-q)? (q-p) : ( p-q); 14 b) Arrange the following primitive data types in ascending order of their size: i) char ii) byte iii) double iv) int byte< char< int < double c) What is the value stored in variable res given below: double res= Math.pow( 345.indexOf( 5 ),3); Ans : 8 b) What is the result stored in x, after evaluating the following expression int x=5; x=x++ * 2 + 3 * --x 25 e) What are the values of a and b after the following function is executed, ifthe values passed are 30 and 50: void paws(int a, int b) a=a+b; b=a-b; a=a-b; System.out.println(a+, +b); Ans : 50 30 Question 3. a) State the data type and value of y after the following is executed: char x= 7 ; y=character.isletter(x); Ans : boolean, false b) What will be the output of the following code? int m=2; int n=15; for(int i=1;i<=15;i++); m++;

--n; System.out.println("m="+m); System.out.println("n="+n); 3 14 c) State the output when the following program segment is executed: String a= Smartphone, b= Graphic Art ; String h=a.substring(2,5); String k=b.substring(8).touppercase( ); System.out.println(h); System.out.println(k.equalsIgnoreCase(h)); Ans : art true d) The access specifier that gives the most accessibility is and the least accessibility is. Ans : public & private f) i) Name the mathematical function which is used to find sine of an angle given in radians. Math.sin() ii) Name a string function which removes the blank spaces provided in the prefix and suffix of a string. trim() f) i) What will this code print? int arr[]= Computer Applications System.out.println(arr.charAt(22)); Ans : Error ii) Name the keyword which is used to resolve the conflict between method parameter and instance variables/fields. Ans : this g) What will the following functions return when executed? i) Math.max(-17,-19) ==== -17 ii) Math.ceil(7.8) ===== 8.0 h) Write the output of the following program code: char ch; int x= 97; do ch=(char)x; System.out.print(ch + ); if(x%10 = =0) ++x; while(x<=100); Ans : a b c d i) Write the Java expressions for: a 2 +b 2 -------- 2ab Ans : (Math.pow(a,2)+Math.pow(b,2))/(2*a*b)

j) If int y=10 then find int z=(++y * (y++ + 5)); Ans : z = 176 Question 4. [ 15 ] Write a program to Accept a number and Check and print whether it is a palindrome number Example Input1 : 1221 Output : 1221 is a palindrome number Input2 : 122 Output : 122 is not a palindrome number public class IXQ4 System.out.println("enter a number "); int n = sc.nextint(); int t = n; // storing the n umber in a temporary variable int rev=0; // to store the reversed number while(t!=0) int d = t%10; rev = rev*10 + d; t /= 10; if (rev == n) System.out.println(n+" is a palindrome number"); System.out.println(n+" is not a palindrome number"); Question 5. Write a program to input a number and print whether the number is a special number or not. (A number is said to be a special number, if the sum of the factorial of the digits of the number is same as the original number). Example: 145 is a special number, because 1! + 4! + 5! = 1 + 24 + 120 = 145 (where! stands for the factorial of the number and the factorial value of a number is the product of all integers from 1 to that number, example 5! = 1*2*3*4*5 = 120).

public class IXQ5 System.out.println("enter a number "); int n = sc.nextint(); int t = n; // storing the n umber in a temporary variable int sum=0; // to store the reversed number while(t!=0) int d = t%10; int f =1; for(int i = 1; i<=d; i++) f *= i; sum +=f; t /= 10; if (sum == n) System.out.println(n+" is a Special Number"); System.out.println(n+" is not a Special number"); Question 6. [ 15 ] Write a program to input and store roll number, name and marks in 3 subjects of a student and display the remark based on average mark as given below: (The maximum marks in the subject are 100) Average marks = Total marks ------------------ 3 Average marks Remark 85-100 EXCELLENT 75-84 DISTINCTION 60-74 FIRST CLASS 40-59 PASS Less than 40 POOR Ans : public class IXQ6

System.out.print("Enter yout name : "); String name = sc.nextline(); System.out.print("Enter yout RollNumber : "); int roll = sc.nextint(); String st = sc.nextline(); // to capture the enter key System.out.println("Enter the three subject marks"); System.out.print("Enter Marks 1: ") ; int m1 = sc.nextint(); st = sc.nextline(); System.out.print("Enter Marks 2: ") ; int m2 = sc.nextint(); st = sc.nextline(); System.out.print("Enter Marks 3: ") ; int m3 = sc.nextint(); st = sc.nextline(); int Avg = (m1+m2+m3)/3; String rem=""; if (Avg >=85 && Avg <=100) rem = "EXCELLENT"; if(avg >=75 && Avg<=84) rem = "DISTINCTION"; if (Avg>=60 && Avg<=74) rem = "FIRST CLASS"; if (Avg>=40 && Avg <=59) rem = "PASS"; rem = "POOR"; System.out.println("Roll \t Name \t Average \t Remarks"); System.out.println(roll +" \t "+ name +" \t "+ Avg+ " \t "+ rem); Question 7. Write a program to accept a number and check and display whether it is a prime number or not and if it is a prime number print its twin prime also if it does not have any print appropriate message. Twin prime numbers : a twin prime numbers are prime numbers and the difference between the two numbers is 2. Example 17 is a prime number and its twin prime is 19. 2 is a prime number but 4 is not a prime number so 2 does not have twin prime. class IXQ7

System.out.println("Enter a number that is Prime"); int num = sc.nextint(); int i; for(i = 2; i<num ;i++) if(num%i ==0) if(i == num) int t = num+2; for(i = 2; i<t ;i++) if(t%i ==0) if (i == t) System.out.println(num+" & "+t+" are twin prime numbers"); t = num-2; for(i = 2; i<t ;i++) if(t%i ==0) if (i == t) System.out.println(t+" & "+num+" are twin prime numbers"); System.out.println(num+" does not have twin prime"); System.out.println(num +" is not a prime number"); Question 8:

Write a program to input a string in uppercase and print the frequency of each character. Example: INPUT: COMPUTER HARDWARE OUTPUT: CHARACTERS FREQUENCY A 2 C 1 D 1 E 2 H 1 M 1 O 1 P 1 R 3 T 1 U 1 W 1 public class IXQ8 // instance variables - replace the example below with your own System.out.println("Enter a String "); String str = sc.nextline(); str = str.touppercase(); System.out.println("CHARACTER FREQUENCY"); for(char ch = 'A'; ch<='z';ch++) int count =0; for(int i = 0 ;i<str.length();i++) if(str.charat(i) == ch) count++; if (count!= 0) System.out.println("\t"+ch + "\t" + count); Question 9. [ 15 ]

Using the switch write a menu driven program to : i) To find and display all the factors of a number input by the user (including 1 and excluding the number itself). Example: Sample input : n = 15 Sample output : 1, 3, 5 ii) To find and display the factorial of a number input by the user ( the factorial of a non negative integer n, denoted by n!, is the product of all integers less than or equal to n. Example: Sample input : n =5 Sample output : 5!=1x2x3x4x5=120 For an incorrect choice an appropriate error message should be displayed. public class IXQ9 System.out.println("1. Display factors of a number"); System.out.println("2. Diaplay factorial of a number"); System.out.println("3. Exit"); int choice = sc.nextint(); int num; switch (choice) case 1: System.out.println("enter the number "); num = sc.nextint(); System.out.print("The factors of "+num+" are "); for(int i= 1; i<num; i++) if (num%i == 0) System.out.print(i+" "); case 2 : System.out.println("enter the number "); num = sc.nextint(); int fact = 1; for(int i = 1;i<=num;i++) fact *= i; System.out.println("the factorial of "+num+" is "+fact);

case 3: System.out.println("you have chose to exit: Thank you"); default: System.out.println("INVALID CHOICE");