This document contains a final examination paper for an Object Oriented Programming course consisting of two sections - Section A with 40 multiple choice questions and Section B with 2 structure questions. The paper provides instructions to answer all questions, covers various CLOs (course learning outcomes) related to OOP concepts like UML, classes, objects, inheritance, polymorphism and exceptions. It tests the students' understanding of Java programming fundamentals including variable scope, data types, control structures, exception handling and more.
AngularJS is an open source,client side JavaScript MVC framework for web application or web sites.
The aim of the project is to provide time-sheet management system using AngularJS.Conventional method of calculating employee’s performance done by tabular format using a Excel sheet.
AngularJS is an open source,client side JavaScript MVC framework for web application or web sites.
The aim of the project is to provide time-sheet management system using AngularJS.Conventional method of calculating employee’s performance done by tabular format using a Excel sheet.
This slide give the basic introduction about UML diagram and it's types, and brief intro about Activity Diagram, use of activity diagram in object oriented programming language..
Welcome to my series of articles on Unified Modeling Language. This is "Session 7 – Deployment Diagram" of the series. Please view my other documents where I have covered each UML diagram with examples
Modern Programming Languages - An overviewAyman Mahfouz
An overview of modern programming languages, with Kotlin as an example. We examine features of these languages including Groovy, Swift, and Go to point the trend in these languages.
This slide give the basic introduction about UML diagram and it's types, and brief intro about Activity Diagram, use of activity diagram in object oriented programming language..
Welcome to my series of articles on Unified Modeling Language. This is "Session 7 – Deployment Diagram" of the series. Please view my other documents where I have covered each UML diagram with examples
Modern Programming Languages - An overviewAyman Mahfouz
An overview of modern programming languages, with Kotlin as an example. We examine features of these languages including Groovy, Swift, and Go to point the trend in these languages.
Slide pembentangan Roadmap Sistem iDBMS, perlaksanaan, masalah, cadangan tambah baik bagi proses-proses dan cadangan-cadangan yang dilakukan sebelum proses pengambilalihan dilakukan.
Semoga cadangan ini dapat diteruskan bagi kesinambungan kemudahaan pengguna warga Kolej Komuniti khususnya dan pihak Kementerian Pengajian Tinggi umumnya.
Name _______________________________ Class time __________.docxrosemarybdodson23141
Name: _______________________________ Class time: __________
Prewriting Instructions for Paper 2 (Final Paper due 4/22)
1. Your choices for Paper 2 are posted on blackboard and also listed below.
2. Choose 1 of these paper options. Notice that each choice also mentions the type of paper (comparison, etc.) My paper choice is: _________________________: paper type: _______________.
3. Read the related essay(s) in your Research and Composition textbook.
4. Thursday: write a tentative thesis for paper 2 (one sentence): ______________________________________________________________________________________________________________________________________________________________________________________________________________________.
5. Thursday: write 5 questions that you will need to answer through research to write this paper (for ex. What is the divorce rate for 2012?) Write legibly please.
1.
2.
3.
4.
5.
6. Thursday: go to the library and use the databases to locate at least three sources that will likely give you the information to answer the five questions above. At least one should be a book, at least one should be a database article. In addition, you may use your textbook, internet, or even refer to a film. Write down the all of the information about each source. You will need this information for a works cited page later or to locate the article and book again. You do not need to answer the questions right away, but if you do find the answers, take notes or make a copy of the source.
Source 1: ____________________________________________________________________________________________________________________________________________________________
Source 2: ____________________________________________________________________________________________________________________________________________________________
Source 3: ____________________________________________________________________________________________________________________________________________________________
7. Have any new questions come to mind? What are they? Write them here:
8. Have you revised your thesis? What is it? ___________________________________
_____________________________________________________________________.
9. Write a tentative first paragraph to paper 2 (this includes your thesis):
10. Turn this in Tuesday 3/25 in exchange for your last Q exercise, M&M Color Distribution.
***You need this prewriting exercise completed to receive your instructions and data for this last Q exercise and parts of this exercise will count for your attendance in a week or so.
See next page
Writing Assignment 2 Choices due on or before 4/22
Here are your choices for Writing Assignment 2 due 4/22. Additional research is required for all choices. Two visuals, tables or figures, are required. Your paper will be in MLA format with a works cited page. This paper is approximately 5 pages including a works cited page.
1. Read the essays in Chapter 8. Go .
Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...Udayan Khattry
Assess your preparation with these Practice Test Questions with Explanation. Questions are Extracted from Highest Rated Course on Udemy which has helped a lot of students to pass the exam with good score.
500+ multiple choice questions with explanation to assess Oracle Certified Associate, Java SE 8 Programmer II preparation.
Highest Rated course on UDEMY
Read the students success stories at:
https://udayankhattry.com/ocp/
Enroll now to receive maximum discount on the course ie. for just $9.99 or ₹640.00, click the link below- https://www.udemy.com/java-ocp/?couponCode=UDAYANKHATTRY.COM
To avail maximum discount on all courses visit: www.udayankhattry.com
The aptitude test consisted tricky questions on core subjects of CSE like C , C++, Java ,Data Structures, Database, Computer Networks, Theory of Computation.
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
💥 Speed, accuracy, and scaling – discover the superpowers of GenAI in action with UiPath Document Understanding and Communications Mining™:
See how to accelerate model training and optimize model performance with active learning
Learn about the latest enhancements to out-of-the-box document processing – with little to no training required
Get an exclusive demo of the new family of UiPath LLMs – GenAI models specialized for processing different types of documents and messages
This is a hands-on session specifically designed for automation developers and AI enthusiasts seeking to enhance their knowledge in leveraging the latest intelligent document processing capabilities offered by UiPath.
Speakers:
👨🏫 Andras Palfi, Senior Product Manager, UiPath
👩🏫 Lenka Dulovicova, Product Program Manager, UiPath
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
As AI technology is pushing into IT I was wondering myself, as an “infrastructure container kubernetes guy”, how get this fancy AI technology get managed from an infrastructure operational view? Is it possible to apply our lovely cloud native principals as well? What benefit’s both technologies could bring to each other?
Let me take this questions and provide you a short journey through existing deployment models and use cases for AI software. On practical examples, we discuss what cloud/on-premise strategy we may need for applying it to our own infrastructure to get it to work from an enterprise perspective. I want to give an overview about infrastructure requirements and technologies, what could be beneficial or limiting your AI use cases in an enterprise environment. An interactive Demo will give you some insides, what approaches I got already working for real.
"Impact of front-end architecture on development cost", Viktor TurskyiFwdays
I have heard many times that architecture is not important for the front-end. Also, many times I have seen how developers implement features on the front-end just following the standard rules for a framework and think that this is enough to successfully launch the project, and then the project fails. How to prevent this and what approach to choose? I have launched dozens of complex projects and during the talk we will analyze which approaches have worked for me and which have not.
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Jeffrey Haguewood
Sidekick Solutions uses Bonterra Impact Management (fka Social Solutions Apricot) and automation solutions to integrate data for business workflows.
We believe integration and automation are essential to user experience and the promise of efficient work through technology. Automation is the critical ingredient to realizing that full vision. We develop integration products and services for Bonterra Case Management software to support the deployment of automations for a variety of use cases.
This video focuses on the notifications, alerts, and approval requests using Slack for Bonterra Impact Management. The solutions covered in this webinar can also be deployed for Microsoft Teams.
Interested in deploying notification automations for Bonterra Impact Management? Contact us at sales@sidekicksolutionsllc.com to discuss next steps.
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
In this insightful webinar, Inflectra explores how artificial intelligence (AI) is transforming software development and testing. Discover how AI-powered tools are revolutionizing every stage of the software development lifecycle (SDLC), from design and prototyping to testing, deployment, and monitoring.
Learn about:
• The Future of Testing: How AI is shifting testing towards verification, analysis, and higher-level skills, while reducing repetitive tasks.
• Test Automation: How AI-powered test case generation, optimization, and self-healing tests are making testing more efficient and effective.
• Visual Testing: Explore the emerging capabilities of AI in visual testing and how it's set to revolutionize UI verification.
• Inflectra's AI Solutions: See demonstrations of Inflectra's cutting-edge AI tools like the ChatGPT plugin and Azure Open AI platform, designed to streamline your testing process.
Whether you're a developer, tester, or QA professional, this webinar will give you valuable insights into how AI is shaping the future of software delivery.
Let's dive deeper into the world of ODC! Ricardo Alves (OutSystems) will join us to tell all about the new Data Fabric. After that, Sezen de Bruijn (OutSystems) will get into the details on how to best design a sturdy architecture within ODC.
1. EXAMINATION AND EVALUATION DIVISION
DEPARTMENT OF POLYTECHNIC EDUCATION
(MINISTRY OF HIGHER EDUCATION)
INFORMATION & COMMUNICATION TECHNOLOGY (ICT)
DEPARTMENT
FINAL EXAMINATION
JUNE 2012 SESSION
FP301: OBJECT ORIENTED PROGRAMMING
DATE: 21 NOVEMBER 2012 (WEDNESDAY)
DURATION: 2 HOURS (2.30PM-4.30PM)
This paper consists of SEVENTEEN (17) pages including the front page.
Section A: Objective (40 questions – answer ALL)
Section B: Structure (2 questions – answer ALL).
CONFIDENTIAL
DO NOT OPEN THIS QUESTION PAPER UNTIL INSTRUCTED BY THE CHIEF INVIGILATOR
(The CLO stated is for reference only)
2. CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING
Page 2 of 17
SECTION A
OBJECTIVE QUESTIONS (50 marks)
INSTRUCTION:
This section consists of FORTY (40) objective questions. Answer ALL questions in the answer booklet.
1. UML is the acronym of _________________________ [CLO1]
A. Unification Multi Language
B. Unify Multimedia Language
C. United Modeling Language
D. Unified Modeling Language
2. Which of the following terminologies is used to describe the data component in UML class diagram. [CLO1]
A. Attribute
B. Method
C. Object
D. Class
3. Which of the following define the best statement of object oriented analysis? [CLO1]
A. The process of defining the problem in terms of real-world objects with which the system must interact
B. The process of defining the components, interfaces, objects, classes, attributes, and operations that will satisfy the requirements
C. The process of defining the problem, scenario, and operations that will satisfy the requirements
D. The process of defining the components, interfaces, objects, classes, attributes, and operations which the system must interact
4. Which of the following statements is correct? [CLO1]
A. Every class must end with a semicolon.
B. Every comment line must end with a semicolon.
C. Every line in a program must end with a semicolon.
D. Every statement in a program must end with a semicolon
3. CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING
Page 3 of 17
5. What is byte code in the context of Java? [CLO1]
A. It is the code written within the instance methods of a class.
B. The type of code generated by a Java Virtual Machine.
C. The type of code generated by a Java compiler.
D. It is another name for a Java source file.
6. Select the best description about data type.
[CLO1]
A. The part of the CPU that does arithmetic.
B. A part of main memory used to store data.
C. The collection of variables that a program uses.
D. A particular scheme for representing values with bit patterns.
7. Why is main() method special in a Java program? [CLO1]
A. It is where the Java interpreter starts the whole program running.
B. Only the main() method may create objects.
C. Every class must have a main() method.
D. The main() method must be the only static method in a program.
8. The act of creating an object of given class is called ___________ [CLO1]
A. Declaration
B. Referencing
C. Instantiation
D. Implementation
9. Which one of the following illustrates proper naming convention in Java programming style? [CLO1]
A. int StudentName;
B. final double MAXVALUE = 3.547;
C. public class compute_Area(){}
D. public static int ReadDouble(){}
4. CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING
Page 4 of 17
10. What value will be the result if you attempt to add an int, a byte, a long and a double? [CLO1]
A. byte
B. int
C. long
D. Double
11. Which of the following statements correctly creates an input stream by user input? [CLO1]
A. BufferedReader kb = new InputStreamReader(System.in);
B. BufferedReader kb = new BufferedReader( );
C. BufferedReader kb = new BufferedReader(InputStreamReader(System.in));
D. BufferedReader kb = new BufferedReader (new InputStreamReader
(System.in));
12. This operator performs an arithmetic or signed right shift. Which of the following is the symbol of the operator? [CLO1]
A. >>
B. >>>
C. <<
D. <<<
13. Which of the following statements is correct to display Welcome to Java?[CLO2]
A. System.out.println('Welcome to Java');
B. System.out.println("Welcome to Java");
C. System.println('Welcome to Java');
D. System.print('Welcome to Java');
14. Given a java class as follows:
In order to compile this program, the source code should be stored in a file _____
[CLO2]
A. Test.class
B. Test.java
C. Test.doc
D. Test.txt
public class Test {}
5. CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING
Page 5 of 17
15. Consider the following code snippet:
What would you write in order to instantiate MyClass? [CLO2]
A. MyClass mc = new MyClass();
B. MyClass mc = new MyClass;
C. MyClass mc = MyClass();
D. MyClass mc = MyClass;
16. Which will legally declare, construct, and initialize an array? [CLO2]
A. int [] myList = {"1", "2", "3"};
B. int [] myList = (5, 8, 2);
C. int myList [] [] = {4,9,7,0};
D. int myList [] = {4, 3, 7};
17. What are the three parts of a counting loop that must be coordinated in order for the loop to work properly? [CLO2]
A. Initializing the condition, changing the condition, terminating the loop.
B. Initializing the counter, testing the counter, changing the counter.
C. The while statement, the if statement, and sequential execution.
D. The while, the assignment, and the loop body.
public class MyClass{
public MyClass()
{ /*code*/ }
}
6. CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING
Page 6 of 17
18. Analyze the following code:
Select the best statement that describes the program [CLO3]
A. The program has compile errors because the variable radius is not initialized.
B. The program has a compile error because a constant PI is defined inside a method.
C. The program has no compile errors but will get a runtime error because radius is not initialized.
D. The program compiles and runs fine.
19. Examine the following code:
What is the output? [CLO3]
A. 1 2 3 4 5 6
B. 0 2 4 6 8
C. 0 2 4 6
D. 0 2 4
20. What is the difference between ‘Exception’ and ‘error’ in Java? [CLO1]
A. Exception class is used for exceptional conditions that user program should catch.
B. Error defines exceptions that are not excepted to be caught by the program.
C. Exception and Error are the subclasses of the Throwable class.
D. All of the above.
public class Test { public static void main(String[] args) { double radius; final double PI= 3.15169; double area = radius * radius * PI; System.out.println("Area is " + area); } }
int count = 0;
while ( count <= 6 )
{
System.out.print( count + " " );
count = count + 2;
}
System.out.println( );
7. CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING
Page 7 of 17
21. The following are keywords in exception handling except [CLO1]
A. try
B. finally
C. caught
D. throw
22. Choose the common exception type [CLO1]
i. NullPointerException
ii. NumberFormatException
iii. SecurityException
A. i, ii
B. i, iii
C. ii, iii
D. i, ii, iii
23. Which is TRUE about assertion? [CLO1]
A. Assertion is a mechanism used by many programming languages to describe what to do when something unexpected happen.
B. Assertion is a way to test some assumption about the logic of a program.
C. Assertion is a part of the program and cannot be removed independently from the program.
D. All of the above.
24. What does exception type in the following program throw? [CLO2]
A. ArithmeticException
B. ArrayIndexOutOfBoundsException
C. StringIndexOutOfBoundsException
D. ClassCastException
public class Test { public static void main(String[] args) { int[] list = new int[5]; System.out.println(list[5]); } }
8. CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING
Page 8 of 17
25. Given the following code:
Which could be used to create an appropriate catch block? [CLO2]
A. ClassCastException
B. IllegalStateException
C. NumberFormatException
D. IllegalArgumentException
26. What will be the output of the following program? [CLO3]
A. finally
exception
finished
B. exception
finished
C. finally
D. Compilation fails
try { int x = Integer.parseInt(“two”); }
public class Test {
public static void aMethod() throws Exception {
try {
throw new Exception();
} finally {
System.out.println(“finally”);
}
public static void main(String args[]) {
try {
aMethod();
} catch (Exception e) {
System.out.println(“exception”);
}
System.out.println(“finished”)
}
}
9. CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING
Page 9 of 17
27. What will be the result of compiling and running the program below? [CLO3]
A. Run time error
B. Compile time error
C. Program compiles correctly and print “A” when executed
D. Program compiles correctly and prints “A” and “C” when executed
28. Which methods can access a private attribute? [CLO1]
A. Only classes in the same package.
B. Only static methods in the same class.
C. Only those defined in the same class.
D. Only instance methods in the same class.
29. Which of the following is the general scheme for a class definition? [CLO1]
A. Class ClassName {
// Description of the instance variables.
// Description of the constructors.
// Description of the methods.}
B. class ClassName {
// Description of the instance variables.
// Description of the constructors.
// Description of the methods.}
C. ClassName {
// Description of the instance variables.
// Description of the constructors.
// Description of the methods.}
D. class ClassName { };
public class Exception {
public static void main(String[] args){
System.out.println(“A”);
try{}
catch(java.io.IOException t) {
System.out.println(“B”);
}
}
}
10. CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING
Page 10 of 17
30. average = calculate (no1, no2, no3)
What is the type of parameter passing based on the above coding. [CLO1]
A. Call by value
B. Call by object
C. Call by parameter
D. Call waiting
31. If a method assigns a new value to a member of an object which can be accessed through an object reference parameter, will this have any effect on its caller?
[CLO1]
A. No, because it only has a copy of the object.
B. No, because it does not allow to do this.
C. Yes, this will change part of the object that both it and the caller are referring to.
D. Yes, the caller will now get a new object.
32. Which one of Java packages below is used for basic language functionality and fundamentals types? [CLO1]
A. java.lang
B. java.util
C. java.math
D. java.io
33. A constructor ________ [CLO1]
A. must have the same name as the class it is declared within
B. is used to create objects
C. maybe declared private
D. all of the above
11. CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING
Page 11 of 17
34. A String class _________________________________________ [CLO1]
i. is final
ii. is public
iii. is serializable
iv. has a constructor which takes a StringBuffer objects as an arguments
A. i only
B. i, ii
C. i, ii, iii
D. All of the above
35. Which of the following is a correct syntax for defining a new class Cupboard based on the superclass Furniture? [CLO 2]
A. class Cupboard isa Furniture { //additional definitions go here }
B. class Cupboard implements Furniture { //additional definitions go here }
C. class Cupboard defines Furniture { //additional definitions go here }
D. class Cupboard extends Furniture { //additional definitions go here }
36. Which three lines of codes are equivalent to line 3? [CLO 2]
i. final int k = 4;
ii. public int k = 4;
iii. static int k = 4;
iv. abstract int k = 4;
A. i, ii, iii
B. ii, iii, iv
C. i, iii,iv
D. All of the above
public interface Foo
{
int k = 4; /* Line 3 */
}
12. CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING
Page 12 of 17
37. What is the output of the following segment program?
[CLO 2]
A. fa fa
B. fa la
C. la la
D. Compilation fails
38. Consider the following coding
[CLO 2]
What is the output?
A. 6
B. river
C. 8
D. Columbia
39. Which of the following defines a legal abstract class?
[CLO 3]
A. abstract class Vehicle { abstract void display(); }
B. class Vehicle { abstract void display(); }
C. abstract Vehicle { abstract void display(); }
D. class abstract Vehicle { abstract void display(); }
public class Tenor extends Singer {
public static String sing(){ return “fa”;}
public static void main(String[] args {
Tenor t = new Tenor();
Singer s = new Tenor();
System.out.println(t.sing() + “ “ + s.sing());
}
}
String river = new String(“Columbia”);
System.out.println(river.length());
13. CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING
Page 13 of 17
40. Which of the statement, is NOT correct to declare an interface?
[CLO 3]
A.
B.
C.
D.
public interface Marker {
}
public interface SomethingIsWrong {
voidaMethod(intaValue);
}
public interface SomethingIsWrong {
voidaMethod(intaValue) {
System.out.println("Hi Mom");}
}
publicRectanglePlus(Point p, int w, int h) {
origin = p;
width = w;
height = h;
}
14. CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING
Page 14 of 17
SECTION B
STRUCTURED QUESTIONS (50 marks)
INSTRUCTION:
This section consists of TWO (2) structured questions. Answer ALL questions.
QUESTION 1
a. Refer to Figure 1, define source program, Java compiler and Java bytecodes. [CLO1]
Figure 1 : Program Flow
(6 marks)
b. Car is a real world object and it has its own characteristics like colour of the car, model of the car and engine capacity. We can drive the car and stop it. Draw an UML class diagram to show the attributes and the behaviors of a car. [CLO2]
(7 marks)
c. Based on your answer in 1(b), write a class definition for class Car by using Java. [CLO3]
(7 marks)
d. Write a program to accept a number from the user. Use the assert statement to determine the entered number is within the valid range between 0 and 20.
[CLO3]
(5 marks)
15. CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING
Page 15 of 17
QUESTION 2
a. Explain briefly the operators below: [CLO1]
i. Conditional operator (2 marks)
ii. Logical operator (2 marks)
iii. Left-shift operator (2 marks)
b. Write a program to get 3 values of array elements from command line with those values in the main() method. Add try and catch block to handle ArrayIndexOutOfBoundsException. [CLO2]
(5 marks)
c. Write a command to enable assertion when you run Java program. [CLO2]
(2 marks)
16. CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING
Page 16 of 17
d. The class Birthday is the parent for the two new classes, YouthBirthday and AdultBirthday. Each of the new classes would ordinarily inherit the greeting() method from Birthday.
YouthBirthday birthday card for young people. This card will add the line "How you have grown!" to the usual birthday greeting. An AdultBirthday birthday card is for old people. This card will add the line "You haven't changed at all!" to the usual birthday greeting.
class Birthday {
int age;
public Birthday ( String r, int years ) {
recipient = r;
age = years;
}
public void greeting() {
System.out.println("Dear " + recipient + ",n");
System.out.println("Happy " + age + "th Birthdaynn");
}
}
Based on the above coding,
17. CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING
Page 17 of 17
i. complete the following definition for class YouthBirthday. [CLO3]
class ______(a)______ extends ________(b)_______
{
public ________(c)_______ ( String r, int years )
{
____________(d)_______ ( r, years )
}
public void greeting()
{
__________(e)___________();
System.out.println("How you have grown!!n");
}
}
(5 marks)
ii. write a new class definition for AdultBirthday with an overriding method greeting() in it. [CLO3]
(7 marks)