Page 7 - CA_Blue( J )_Class10
P. 7

Note: This section provides a tip to the user which is relevant to the current topic.



                                                  Assessment Resources





                                                                                     Previous Years' Questions
                                    MIND DRILL                                             SECTION A
                                                                            1.  Write the output:               [2017]
                     Solved Questions                                           char ch = 'F';
                                                                            int m = ch;
                                                                              m = m + 5;
                   A.  Tick ( ) the correct answer.                           System.out.println(m + " " + ch);
                      1.  String is a ………………….                             Ans.  75 F
                      a.  Class        b.  Data type                        2.  Write the output for the following:   [2017]
                      c.  Object       d.  Interface                          String s = "Today is Test";
                      2.  Which of the following keyword, is used to create the object of the String class dynamically?     System.out.println(s.indexOf('T'));
                      a.  object       b.  static                             System.out.println(s.substring(0, 7) + " " + "Holiday");
                      c.  new          d.  public                          Ans.  0
                      3.  From where the index value of the String object is started?      Today i Holiday
                      a.  0            b.  1                                3.  State the output when the following program segment is executed:   [2015]
                      c.  2            d.  3
                                                                              String a = "Smartphone", b = "Graphic Art";
                      4.  Which of the following methods returns the character in the given index?      String h = a.substring(2, 5);
                      a.  charAt()     b.  indexOf()                        String k = b.substring(8).toUpperCase();
                      c.  substring()   d.  equals()     7.  What is the output of the following statements?     System.out.println(h);
                      5.  Which type of value the toLowerCase() method will return?     System.out.println(k.equalsIgnoreCase(h));
                                                                           Previous Years' Questions: This section
                                                                           Ans.  art
                      a.  int          b.  char  String a = "Java is a programming language\ndeveloped by\t\'James Gosling\'";
                      c.  String       d.  boolean  System.out.println(a);  true
                 Mind Drill: This section contains objective                  4.  Write the output of the following program code:   [2015]
                     6.  Which of the following methods is used to extract a set of characters from a string? Ans.  Java is a programming language

                                                                            contains questions from the previous

                                       b.  equals()
                                               developed by    'James Gosling'


                     a.  trim()
                                                                            char ch;

                     c.  length()
                                       d.  substring()
                 and subjective questions for assessment.            (ii)  "TRANSPARENT".compareTo("TRANSITION") years board exams.


                                              8.  Give the output of the following Java statements:
                                                                            int x = 97;
                     7.  Which of the following methods replaces all the occurrences of a character in the string with the provided character?

                                                                            do{

                                               (i)  "TRANSPARENT".toLowerCase()

                                       b.  charAt()

                     a.  replace()

                                                                                ch = (char)x;
                      c.  concat()     d.  None of these  Ans.  (i)  transparent   (ii)  7         System.out.print(ch + " ");
                      8.  What will be the output of the following statement:      9.  Write a Java statement for each to perform the following tasks:         if(x % 10 == 0)
                      System.out.println("Orange Education".substring(7));     (i)  Find and display the position of the last space in a string str.             break;
                      a.  Orange       b.  Education                              ++x;
                      c.  Orange Education   d.  Nothing will print    (ii) Extract the second character of the string str.     }while(x <= 100);
                                                                           Ans.  a b c d
                      9.  Which of the following is the return type of the startsWith() method?    Ans.  (i)  System.out.println(str.lastIndexOf(' '));   (ii)  char ch = str.charAt(1);
                      a.  int          b.  double                           5.  State the output of the following program segment:
                      c.  boolean      d.  char  D.  Assertion and Reasoning based questions.     String str1 = "great"; String str2 = "minds";
                      10.  Which of the following methods is used to delete the leading and trailing spaces from the current String object?      (R). Answer these questions by selecting the
                                                                            System.out.println(str1.substring(0, 2).concat(str2.substring(1)));
                                               The following questions consist of two statements – Assertion (A) and Reason
                      a.  endsWith()   b.  trim()  appropriate option given below:  System.out.println(("WH" + (str1.substring(2).toUpperCase())));   [2014]
                      c.  space()      d.  equals()     a.  Both A and R are true, and R is the correct explanation of A.      Ans.  grinds
                      11.  Which of the following statements is true about strings in Java?     b.  Both A and R are true, but R is not the correct explanation of A.       WHEAT
                      a.  Strings are mutable.   b.  Strings are immutable.  c.  A is true, but R is false.       6.  What is the data type returned by the library functions:

                      c.  Strings are primitive data types.   d.  Strings can be null but not empty.   (i)  compareTo()   (ii)  equals()   [2014]
                      12.  What is the result of the following code snippet?     d.  A is false, but R is true.      Ans.  (i)  int   (ii)  boolean
                      String str1 = "Hello";     1.  Assertion (A): A string is a sequence of characters enclosed between double quotes.
                                                                           7.  State the value of characteristic and mantissa when the following code is executed:

                      String str2 = "Hello";   Reason (R): It helps to store a set of characters directly in the object of the String class.

                                                                            String s = "4.3756";
                      System.out.println(str1.equalsIgnoreCase(str2)==false);     int n = s.indexOf('.');
                      a.  true         b.  false     2.  Assertion (A): The equals() method is used to compare the contents of two strings.
                      c.  Compilation error   d.  Runtime error  Reason (R): The == operator compares the references of two string objects.       int characteristic = Integer.parseInt(s.substring(0, n));
                                         Assertion and Reasoning Based Question: This
                                                                            int mantissa = Integer.valueOf(s.substring(n + 1));
                                                                                          mantissa = 3756
                                              3.  Assertion (A): The substring() method can change the original string.

                                                                           Ans.  characteristic = 4
                                               Reason (R): substring() method extracts a part of a string from the original string.
                                        contain assertion and reasoning based questions
                                              Ans.  1. a      2. a     3. d
                    434434  Touchpad Computer Applications-X                      21 st
                                                                                   #Experiential Learning
                                            E.  Case-based questions.
                                                                                Century
                                        to develop logical reasoning skills of the students.               String Handling  443
                                                                                 Skills
                                                                                                                  443
                                               The substring() method in Java is used to extract a portion of a string. It is a part of the String class and provides a way to create
                                               new strings based on a range of characters from an existing string.
                                               Syntax: There are two overloaded versions of the substring() method:
                                                  a. substring(int beginIndex) : Extracts a substring starting from the specified beginIndex to the end of the string.
                                                  String str = "Hello, World!";
                                                  String sub = str.substring(7); // "World!"
                                                  b. substring(int beginIndex, int endIndex) : Extracts a substring starting from the specified beginIndex to endIndex 1.
                                                   String str = "Hello, World!";
                                                   String sub = str.substring(0, 5); // "Hello"
                                               1.  What is the purpose of the substring() method in Java?
                                               a.  To modify the original string   b.  To extract a portion of a string
                                               c.  To compare two strings   d.  To reverse a string
                    INTERNAL ASSESSMENT       2.  In which class is the substring() method defined?  SAMPLE PROJECT
                                               a.  StringBuffer      b.  StringBuilder
                                               c.  String            d.  Arrays
                    Marks: 100                 3.  Which of the following is a valid use of substring(int beginIndex)?
                                               a.  String str = "Hello"; String sub = str.substring();  21 st   #Creativity & Innovativeness
                                               b.  String str = "Hello"; String sub = str.substring(7, 12);   BANKING SYSTEM  Century   #Collaboration & Teamwork
                                                                                                       Skills
                                               c.  String str = "Hello, World!"; String sub = str.substring(7);

                    [These programs are indicative only. Teachers and students should use their imagination to create innovative and
                    original assignments.]     d.  String str = "Hello, World!"; String sub = str.substring("World");  Write a program to simulate a banking system in which the user can create a new account, withdraw money,
                                               4.  What will be the output of the following code?  deposit money, check the existing amount in their account and also check how many people have an account in
                      PROGRAMS ON USER-DEFINED METHODS  String str = "Hello, World!";  that bank.
                    (a)  Program depicting the concept of pure method.
                                                                            1 import java.io.*;
                                                                                           437
                                                                                    String Handling
                    Program 1  Write a pure method boolean palindrome(int) which takes a value, checks whether it is a palindrome   2 import java.util.*;  437
                         number or not. If palindrome then return true else return false.
                                                                            3 class Account
                     1  import java.util.*;                                 4 {
                     2  class palindrome_method                             5   String Name,Password;
                     3  {                                                   6   int Ac_Num,Total_Amt;
                  Internal Assessment: This segment is                      7   int day,month,year;
                           boolean palindrome(int n)           // Pure Method
                     4
                           {
                     5
                                                                            8   public Account(String n,int an,int d,int m,int y,int mon,String p)
                  totally practical-oriented and helps the               Sample Project: This section contains
                     6
                               int temp,rem,rev=0;           // Declaration of variable
                                                                            9   {
                                                                             a real-life application to use the
                     7
                               temp=n;
                 students in acquiring basic programming                    10     Name=n;
                     8
                               while(temp>0)             // Digit extraction
                                                                            11     Ac_Num=an;
                     9          {                                           12     day=d;  concepts learnt.
                        skills quickly and efficiently.
                     10              rem=temp%10;                           13     month=m;
                     11              rev=rev*10+rem;
                                                                            14     year=y;
                     12              temp=temp/10;                          15     Total_Amt=mon;
                     13          }
                                                                            16     Password=p;
                     14  // checking whether reverse of digit is same as original number
                                                                            17   }
                     15          if(rev==n)
                     16              return true;                           18   public void displayData()
                     17          else                                       19   {
                     18              return false;                          20       System.out.println(Ac_Num+"\t"+Name+"\t\t"+day+"/"+month+"/"+year+"\t"+Total_
                                                                             Amt+"\t\t\t"+Password);
                     19      }                                              21   }
                     20      void main()                                    22 }
                     21      {   Scanner sc= new Scanner(System.in);
                                                                            23
                     22          int num;
                                                                            24 public class Bank
                     452452  Touchpad Computer Applications-X               25 {
                                                                                                                  481
                                                                                                            Sample Project  481
   2   3   4   5   6   7   8   9   10   11   12