Page 237 - ComputerScience_Class_11
P. 237

C.  Answer the following questions:

                    1.  What is the scope of a variable in Java?
                    2.  What is the purpose of declaration statements in Java?
                    3.  Explain control statements in Java.
                    4.  What is the difference between an if statement and an if-else statement?
                    5.  What does a switch-case statement do in Java?
                    6.  What is the significance of the break statement in control flow?
                    7.  How can you handle multiple conditions in a switch-case statement?
                    8.  What is a for loop and when is it used in Java?
                    9.  What is a nested ‘if’ statement in Java? Explain with an example where a nested ‘if’ statement is useful.
                    10.  What is a ‘switch case’ statement? Illustrate with examples.
                    11.  Describe the concept of Fall Through in a ‘switch case’ statement. Provide a program that demonstrates Fall Through behaviour.
                    12.  What are iterative statements in Java? Explain with examples how ‘for’, ‘while’ and ‘do-while’ loops work.
                    13.  What  is  the  difference  between  an  entry-controlled  loop  and  an  exit-controlled  loop?  Provide  examples  using  ‘for’  and
                       ‘do-while’ loops.
                    14.  Write a Java program using a ‘for loop’ to check if a number is a perfect number.
                    15.  How does a ‘while loop’ work in Java? Provide an example of a program that uses a while loop to check if a number is a sum
                       product number.
                    16.  What is the ‘continue’ statement in Java? Write a program to calculate the average of the first 10 even numbers using the
                       ‘continue’ statement.
                 D.  Higher Order Thinking Skills (HOTS)
                    1.  In a customer feedback analysis system, a company's support team needs to categorise feedback into "Positive", "Negative" and
                       "Neutral" categories based on sentiment scores. However, the sentiment score can have overlapping values. How would you
                       handle the situation using a combination of control structures to ensure proper categorisation, especially when scores are bor-
                       derline?
                    2.  A software company is developing a subscription pricing model that depends on the number of users.
                        The company offers tiered discounts as follows:
                        •  Basic Plan: For up to 500 users, the price per user is Rs. 100.
                        •  Standard Plan: For 501 to 1500 users, the price per user is Rs.400.
                        •  Premium Plan: For 1501 to 5000 users, the price per user is Rs.800.
                        •  Enterprise Plan: For more than 5000 users, the price per user is Rs. 1000.
                        The system also needs to apply an additional loyalty discount:
                        •  5% discount for customers who subscribe for more than 12 months.
                        •  10% discount for customers who subscribe for more than 24 months.
                        How would you design a control flow using if-else or switch statements to ensure that the correct pricing and loyalty discounts
                       are applied based on both the number of users and the subscription duration? Explain the logic behind the control flow and how
                       it handles the decision-making process.

                 E.  Case study-based questions.
                      Aakash is working on a project management system for his small software company. He is learning Java to automate the scheduling
                    of tasks for his team. The system needs to prioritise tasks based on their urgency and time required for completion.
                      There are three categories of tasks:
                      High Priority: Tasks that must be completed immediately (time required is 1 hour or less).
                      Medium Priority: Tasks that need attention soon (time required is between 1 and 3 hours).
                      Low Priority: Tasks that can be deferred (time required is more than 3 hours).
                      To automate the scheduling process, Aakash used if-else-if statements to prioritise tasks based on their urgency and time required.
                    However, while testing the program, he encountered an issue: when the time required was exactly 1 hour or 3 hours, the system did
                    not classify the tasks correctly.






                                                                                              Statements and Scope  235
   232   233   234   235   236   237   238   239   240   241   242