What behaviors can the Bank Account object perform?
Click to see answer
deposit() and withdraw().
Click to see question
What behaviors can the Bank Account object perform?
deposit() and withdraw().
What do instance methods provide in classes?
They provide the interface of classes.
Give an example of an instance variable.
private double balance;
What does 'account1' represent in the statement 'Account account1 = new Account(100);'?
It is an object reference to an instance of the Account class.
When is the exam scheduled?
In January, with the date to be confirmed (TBC).
What type of variable is 'accountNum' in the Account class?
It is a private String variable.
What is included in the parameter list of a method?
The type and name of parameters.
What is an instance variable?
An instance variable can hold a single value or an object.
What is the syntax to create a new object of the Account class in Java?
Account account1 = new Account(100);
What is the importance of information hiding in industry?
It is essential for maintaining encapsulation and security in software design.
What must a constructor have in relation to the class name?
The constructor must have the same name as the class name.
What is required to create instances of a class?
We need to call the constructor of the class using the new keyword.
How can an instance of 'Account' be declared?
Account account1 = new Account(100);
Where are the tutorials held?
On-site.
What is the name of the class represented in the UML diagram?
BankAccount.
How do we create an object in Java?
By calling the constructor of the class using the new keyword.
What are the instance variables in the Account class?
balance (double) and accountNum (String).
What access modifier is used to declare class variables for encapsulation?
Private.
What is the purpose of the 'new' keyword in Java?
It is used to create new instances of a class.
How does the deposit method affect the balance?
It increases the balance by the specified amount.
Is the following method overload valid: public void deposit(double amount) and public void deposit(double amount, double interest)?
Yes, because they have a different number of parameters.
What does abstraction allow us to do with classes?
Create one class to represent several objects.
What are the instance variables in the Account class?
balance (double) and accNumb (String).
What is the state of a bank Account class?
Attributes such as account number and balance.
What is the typical access modifier for instance methods?
Public.
What is the default value of an uninitialized variable in Java?
It is null.
How do you declare a null reference for an Account object in Java?
Account account1 = null;
What is the function of the setBalance method?
To update the account's balance with a new value.
What do all objects that share similar characteristics or behaviors belong to?
The same class.
Why is learning programming considered a valuable life skill?
It enhances creativity, systematic thinking, and collaborative work.
What operations (behavior) can be performed on the class Time?
Set Hours, Set Minutes, and Set Seconds.
What is one advantage of Object-Oriented (OO) programming?
People think in terms of objects.
How are the variables of a class accessed in encapsulation?
Only through the methods of their current class.
Why are OO models considered easy to understand?
Because they reflect real-world concepts and objects.
What does the withdraw method do?
It decreases the balance by the specified amount.
What does the 'private' access modifier restrict?
It restricts access to the entity only from within the class itself.
What is the general practice for instance variables in terms of access modifiers?
Instance variables are generally declared as private.
What principle should be described and justified in OOP?
Concurrency principle and how threads can be implemented.
What is the difference between values and references?
Values are actual data, while references point to the location of the data in memory.
What is an example of an account with a balance of £20,000?
A0456.
What operation would you use to add money to a bank account?
Deposit.
What is Ben in the context of object-oriented programming?
A Tangible Object instance of the class Person.
What behaviors (operations) are associated with the class Person?
Walks and Eats.
How can objects be categorized in Object Oriented programming?
Into classes.
What is the title of the book by C. Horstmann?
Big Java, 4th edition.
What is 11:00:00 in the context of Object Oriented Programming?
It is a time and an instance of the class Time.
What are the attributes (state) of the class Time?
Hours, Minutes, and Seconds.
Who are the authors of 'Design Patterns: Elements of Reusable Object-Oriented Software'?
Gamma, Helm, Johnson, Vlissides.
What is the convention for naming a class in Java?
A class name always starts with a capital letter.
How do OO models relate to reality?
OO models map to reality.
What is the purpose of the Account class?
To manage a bank account's balance and transactions.
What is the purpose of the constructors in the Account class?
To initialize objects and create instances.
What is the access modifier for the 'withdraw' method?
Public.
What are instance methods?
Operations defined in a class that can be performed on instances of that class.
What does the 'close' method do in the BankAccount class?
It closes the bank account.
What is the general practice for instance methods and constructors in terms of access modifiers?
Instance methods and constructors are generally declared as public.
What is the default value of 'balance' in the default constructor of the Account class?
Who can access public instance methods?
Members of other classes.
What is plagiarism defined as?
An act of fraud involving stealing someone else's work and lying about it afterward.
What is the access modifier for the deposit method?
public.
Is it acceptable to copy code from external sources?
No, you should not copy the code from external sources.
What type of variable is 'balance' in the Account class?
It is an instance variable representing the account balance.
What is the focus of 'The Object Oriented Thought Process'?
Object-oriented programming concepts.
How do you create a new instance of the Account class with a parameter?
account2 = new Account(100);
What is a reference in the context of a variable?
A pointer or a form of memory address.
Does a variable hold the object itself?
No, it holds a reference to the object.
What does behavior refer to in a class?
The actions that an object can perform, such as Speak, Deposit, Work, etc.
What methods are provided to modify and view variable values in encapsulation?
Public setter and getter methods.
What is the function of the 'close' method in the Account example?
Closes the account.
What can be implemented using OOP languages?
GUI interfaces.
What principles does the module teach to apply?
Principles of object-oriented programming, OOP analysis, and design.
What is a Model in the context of programming?
A representation of a real-world system or concept.
What are the names of two account instances mentioned?
BobAcc and JaneAcc.
What is the role of Graphical User Interfaces (GUIs) in OOP?
To provide a visual interface for user interaction with applications.
What does it mean when we say 'they are the same object' in the context of object references?
It means that the object reference points to the same memory location for both the method and the caller.
What does 'Object Oriented' programming typically create?
A model of a part of the 'real' world.
What represents the identity of the instance Ben?
His name.
What does the getAccountNum method return?
It returns the account number.
What does the method name in a method declaration represent?
It is the name you choose for the method.
What is an object that belongs to a class called?
An instance of that class.
What rules apply to constructor overloading?
The same rules that apply for method overloading.
What is the importance of attending lectures and tutorials on time?
To ensure you do all tutorial exercises and in-lecture exercises.
How can programming problems be approached according to the course objectives?
By decomposing them using object-oriented analysis and design.
What are attributes in a class?
Characteristics that describe the class, such as Name, Age, Balance, Salary, etc.
What are the fundamental building blocks in Object-Oriented Programming?
Objects and Classes.
What does the 'getBalance' method do?
Prints the balance of the account.
What is the purpose of a constructor in a class?
To initialize instance variables when an object is created.
What is the purpose of a constructor?
To initialize an object when it is created.
What does the constructor 'public Account(double initialBalance, String accountNum)' do?
It initializes the balance and account number for the Account object.
What methods are typically included in a BankAccount class?
withdraw(), deposit(), getBalance(), close().
What are the data types of 'var1' and 'var2' in Object 2?
Both are int.
What is the balance of the account with account number A0456?
20000£.
What is UML used for in OOP?
To design classes and represent the structure of a system.
What is polymorphism in OOP?
The ability of different classes to be treated as instances of the same class through a common interface.
What is a class in object-oriented programming?
A blueprint or template for creating objects (instances).
What are the state attributes of the class Person?
Name and Age.
What interaction occurs between Ben and the Ferrari?
Ben drives the Ferrari.
What is the purpose of the getBalance method in the Account class?
To return the current balance of the account.
What is the purpose of the 'new' keyword in Java?
It is used to create a new object instance.
What is the type 'Account' in programming?
A new type that allows for user-defined declarations.
Where can you find the PDF of the lecture materials?
On Blackboard before the lecture.
What does the identity of an object in the class Time refer to?
It would have a unique ID in the model.
What is an important aspect of programming in a team setting?
Collaborative work.
What do instance methods represent in an object?
The behavior and state alteration of an object.
What makes OO models easy to develop?
They map to reality and align with how people think.
What type of variable is 'balance' in the Account class?
It is a private double variable.
What method would you use to withdraw money from an Account?
withdraw(double amount).
Which method in the Account class returns the current balance?
getBalance().
What is an object in the context of classes?
An instance of a class.
What does the module 5COSC001W introduce?
The concepts of objects and classes.
What is the aim of the module regarding programming skills?
To extend the programming skills acquired in the first year.
What does Real World Model refer to?
A conceptual framework that mirrors real-life entities and their interactions.
What does Design involve in programming?
Creating a blueprint for how a program will function and be structured.
What is the significance of Input/Output and streams in programming?
They are essential for reading from and writing to various data sources.
What is an object in programming?
An object is something tangible (like a person or a pen) or something that can be apprehended intellectually (like time or date).
What are examples of objects in the OO model?
Ben, Flat 7, Ferrari.
What are the components of the model in Object Oriented programming?
Objects that can be identified in the problem.
What does the term 'interaction' refer to in the OO model?
The relationships or actions between objects.
Give an example of an object and its class.
Ben is an instance of the class Persons.
What must be considered when calling a constructor?
We need to call the constructor with the correct parameters and types.
What is encapsulation in OOP?
Wrapping the data (variables) and code (methods) together as a single unit.
What is the purpose of constructors in a class declaration?
To initialize objects.
What is method overloading?
The ability to have more than one method with the same name in the same class.
What is a key practice in the development of object-oriented (OO) software?
Identifying and justifying good practices.
What should you apply when working with OO programming languages?
Acquired knowledge of concepts and programming languages based on OO principles.
What are the main steps in creating an application based on OOP?
Design, implement, and test the application.
What is the purpose of the BankAccount class?
To manage bank account operations such as balance management and transactions.
What method would you use to withdraw money from a BankAccount?
withdraw(amount: double): void.
What logic is used in Object 3?
Print String concatenation.
What is the balance of the account with account number A0123?
15000£.
What is the purpose of abstraction in OOP?
To hide complex implementation details and show only the essential features of an object.
What are the attributes of the Person object named 'Bob'?
Name: 'Bob', Age: 22.
What does a class define for its instances?
The structure and behaviour that its instances (objects) will have.
What happens when a variable is set to null?
No methods can be called on it since it does not reference any object.
What is an object in programming?
An object is something tangible (like Ben or a Ferrari) or something that can be apprehended intellectually (like Time or Date).
What is the return type of the deposit method?
void.
Can a class have more than one constructor?
Yes, a class can have more than one constructor.
What is it called when a class has multiple constructors?
Constructor overloading.
How does programming enhance creativity?
It involves problem-solving skills.
What should you do if you encounter problems during the course?
Flag any problems you have early.
What should you be able to do after completing the course?
Tackle more complicated programming problems.
What is another term for encapsulation?
Data hiding.
What type of variable is 'accountNum' in the BankAccount class?
Private (String).
What is the standard structure of a class declaration in Java?
public class class_name { variable - declarations, constructor - declarations, method - declarations }
What must be different for overloaded methods?
They must have a different number of parameters or parameters of different types.
How is object creation in Java similar to variable declaration?
Both involve declaring a variable and assigning it a value, like 'int x = 5' and 'Account account1 = new Account(100);'.
What does the deposit method do in the Account class?
It adds a specified amount to the account balance.
What are the instance variables of the BankAccount class?
balance (double) and accountNum (String).
How can you check the balance of a BankAccount?
By using the getBalance(): double method.
What is the purpose of Program Analysis?
To evaluate and understand the structure and behavior of a program.
What is concurrency in programming?
The ability to execute multiple sequences of operations simultaneously.
What does the 'I' in OOP principles stand for?
Inheritance.
How can different objects communicate with each other?
Via their instance methods.
What interaction occurs between Ben and Flat 7?
Ben lives in Flat 7.
When will the lab-based practical assessment take place?
During the seminar in week 11.
What is the initial balance set for the account in the example?
Can you use ChatGPT to generate code for academic purposes?
No, you cannot use ChatGPT to generate code.
What is expected regarding attendance at lectures and tutorials?
You must attend all lectures and tutorials (seminars).
What is the purpose of the deposit method?
To add a specified amount to an account.
What does a variable of a class type hold?
A reference to an object.
What does a class declaration typically contain?
Declarations of instance methods and instance variables.
What is the syntax to create an instance of the Account class?
Account account1 = new Account(100);
What is an access modifier in programming?
It is a declaration that defines the accessibility of an instance variable, constructor, or method.
What programming language knowledge is expected to improve after this course?
Knowledge of the Java programming language.
What is a class declaration?
It defines a new class in programming.
What are instance variables?
Properties or data that hold the state of an object in a class.
What is the main focus of abstraction in OOP?
To focus on the essential quality of an object and discard what is irrelevant.
What are the attributes of the BankAccount class?
balance (double) and idNumber (String).
What are the data types of 'var3' and 'var4' in Object 3?
Both are String.
What logic is applied in Object 2?
Sum = var1 + var2.
What operation would you use to terminate a bank account?
Close account.
What are fundamental design patterns?
Reusable solutions to common problems in software design.
What is encapsulation in OOP?
The bundling of data and methods that operate on that data within a single unit or class, restricting access to some components.
What does the null keyword represent in programming?
It indicates that no object is referenced.
What formats are included in the exam assessment?
Multiple choice questions, fill-in the blanks, analyzing code snippets, and filling UML diagrams.
What should you not do with code from other students?
Do not copy the code from other students.
What does the setAccountNum method do?
It sets a new account number for the account.
Who is the author of 'Java: A Beginner’s Guide'?
Herbert Schildt.
How do you create a new instance of the Account class without parameters?
account1 = new Account();
What type of thinking does programming teach?
Systematic thinking and logical reasoning.
How many constructors were implemented for the Account class?
Two constructors.
What type of variable is 'balance' in the BankAccount class?
Private (double).
What programming concepts should you be familiar with after the course?
Most of the object-oriented programming concepts.
What happens to an object if its variable goes out of scope?
The object can still exist if referenced by another variable.
What is the return type of the 'getBalance' method?
double.
What is the purpose of the close() method in the Account class?
To perform actions related to closing the account.
What happens when the close method is called?
It sets the balance to zero.
What is method overloading?
Defining multiple methods with the same name but different parameters.
What is an example of an account with a balance of £15,000?
A0123.
What are the two example accounts mentioned?
BobAcc and JaneAcc.
How does Abstract form relate to Code?
It serves as a conceptual framework that guides the implementation of the actual code.
What is defensive programming?
A practice aimed at improving software robustness by anticipating potential errors.
What is inheritance in OOP?
A mechanism where a new class derives properties and behavior from an existing class.
What happens if an object reference is passed as a parameter to a method?
Changing the object inside the method changes the object outside the method.
What type of assessment involves coding exercises during seminar slots?
Lab-based Practical.
Why are instance variables typically defined as private?
To facilitate information hiding between classes.
What is the relationship between an object and a class?
An object is an instance of a class.
What type of variable is 'balance' in the Account class?
It is a private double variable.
What do we want our class to represent?
A grouping of conceptually-related state and behavior.
What is 'Account' classified as?
A User Defined Type.
How do you call an instance method on an object?
Using the syntax object_name.method_name(arguments).
What is the purpose of the deposit method in the example?
To add money to the account, e.g., account1.deposit(1000).
What is a class in programming?
A blueprint for creating objects, such as Person, BankAccount, Employee, Time, etc.
What does the 'deposit' method do in the Account example?
Increases the balance of the account by a specified amount.
What does the line 'Account account1 = new Account(100);' do?
It declares a variable named account1 of type Account and assigns it a new Account instance with a value of 100.
What does the 'public' access modifier allow?
It allows the entity to be accessed by other classes.
Can one object be referenced by multiple references?
Yes, one object can be referenced by several references and variables.
What is the return type of the getBalance method?
It returns a double value representing the current balance.
What does object assignment refer to?
Assigning one object to another.
What is the age assigned to the variable 'age' in Object 1?
What does the close() method do in the BankAccount class?
It closes the bank account.
What does the 'A' in OOP principles stand for?
Abstraction.
What are the three main characteristics of an object?
State, behavior, and identity.
Which book discusses design patterns in object-oriented software?
Design Patterns: Elements of Reusable Object-Oriented Software.
What is the name of the class defined in the code?
Account.
What does the withdraw method do in the context of the example?
It removes money from the account, e.g., account2.withdraw(250).
What action does the close method perform?
It closes the account, e.g., account2.close().
What is the purpose of the 'withdraw' method in the Account example?
Decreases the balance of the account by a specified amount.
Is the order of declarations in a class important?
No, the order is not important, but there is a standard way.
Is the following method overload valid: public void deposit(double amount) and public void deposit(double money)?
No, because they have the same parameter type.
What are the two main components represented in a UML class diagram?
State and Behaviour.
What is the data type of the variable 'name' in Object 1?
String.
What logic is applied in Object 1?
Print name; Print age.
What are the behaviors of a bank Account class?
Operations like Withdraw, Deposit, Get balance, and Close account.
Which operation allows you to check the current amount in a bank account?
Get balance.
What does computational modeling involve?
Creating abstract models to simulate real-world processes.
What are the attributes of the Person object named 'Jane'?
Name: 'Jane', Age: 33.
What is the significance of having multiple constructors in a class?
It allows for different ways to initialize an object.
What attribute represents the unique identifier for a bank account?
Account number.
What operation would you perform to remove funds from a bank account?
Withdraw.
What is unit testing?
A software testing method where individual components are tested for correctness.
What does the 'E' in OOP principles represent?
Encapsulation.
What is meant by Abstract form in programming?
A simplified representation that focuses on essential characteristics while ignoring irrelevant details.
What is the purpose of classes and objects in OOP?
They are fundamental building blocks for creating and organizing code.
What are the attributes of the Bank Account object?
Number: 01 23 45, Balance: 200 £.
What are the key principles of Object Oriented Programming?
Inheritance, polymorphism, abstraction, and encapsulation.
What does the 'P' in OOP principles represent?
Polymorphism.
What behaviors can the Person object perform?
speak() and walk().