COSC FINAL

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

2

Attributes of an object are also known as porperties Which one of the following is the process where an object of one class receives the properties of objects of another class?Inheritance What is the main goal of Object oriented programming?Ease of evolution.Polymorphism related to :OOPWhich from the following is a feature that allows us to perform a single action in different ways. PolymorphismT he process by which objects of one class acquire the properties of objects of another class is known asInheritance Pick the term that relates to polymorphismDynamic binding An object that has more than one form is referred to asPolymorphism Which of the following is not a part of OOP?Multitasking Hiding complexity can also be termed asAbstraction Which of the following concepts of OOPS means exposing only necessary information to client?Abstraction How many objects can be made from a class?As many as you want What is the difference between a class and an object?Class is a blueprint to make an object Which one is not the basic element of OOP?blue jAn object is an instance of a:Class These have identity, state, and behavior.Object As a blueprint is a design for a house, a class is a design for a(n):Object The process by which objects of one class acquire the properties of objects of another class is known asInheritance The wrapping up of data and functions into a single unit is calledEncapsulation Which of the following statements is incorrect?Class is an instance of an object32. Programming Languages where the programmer specifies the steps that must be carried out in order to achieve a result.Procedural Programming Languages33. A programming paradigm that encapsulates instructions and data together into objects.Object oriented programming34. SubclassClass devised from another class42. Method that is called when an object is instantiated from a class to initialise the object....ConstructorOOP stands for Object-_____ Programming.OrientedA _____ is a template or blueprint from which objects can be instantiated from.ClassA ___________ is a subroutine defined within a class to implement a behaviour.MethodAn ___________ (or property) is a variable defined within a class to store a value.Attribute___________: When a sub-class inherits the methods and properties of a parent class.InheritanceAn _____ is an instance of a class.ObjectAn ________ Class which will not be used to instantiate objects.Abstract______________: "Hiding" properties and methods of a class from the "outside world" by making these private.EncapsulationOver-loading _______________: Implementing a method multiple times to accept different parameters.PolymorphismOver-riding _______________: Implementing an inherited method differently in a sub-class.PolymorphismA ___ class, also called child class or derived class, inherits the methods and attributes from its parent class. .SubA ___________ method or property can be accessed from outside the class.Public A ___________ method or property cannot be accessed from outside the class.Private A ___________ is a public method used to retrieve the content of a private property.Getter A ___________ is a public method used to set/overwrite the content of a private property.Setter ___________ inheritance: When a class has two or more parent classes.Multiple A ___________ is a method of a class that is automatically called when a new object is instantiated from this class.constructor

3

function declaration declaration of a function, including its name, argument types, and return type. signature defines the inputs and outputs for a function=prototype=declaration prototype software/hardware product that is not complete, but is representational of the final product.=signature=declaration instance concrete occurrence of any object,=object class extensible program-code-template for creating objects object abstract data type with the addition of polymorphism and inheritance=instance class method A method that can be called from the class itself.method of a class that is common to all instances of a class and is not called on any specific object instance. These are sometimes referred to as static variables and static methods attribute an attribute is a specification that defines a property of an object, element, or file. It may also refer to or set the specific value for a given instance of such. stance (n.) a way of holding the body; an attitude or position on an issue instance variable a variable defined in a class for which every object of the class has its own value static method a method with no implicit parametergeneral in a class(className, methodCan) instance method A method with an implicit parameter; that is, a method that is invoked on an instance of a class.ex ---- > str=str.trim();tells it to do something Upgrade to remove ads Only $35.99/year numeric code for 'A' 65 numeric code for 'a' 97 numeric code for '0' 48 Write a general Java method, countCharacters, that receives a String and a character, the method returns the number of times the received character appears in the received String.method signature: public static int countCharacters(String word, char ch) public static int countChar(String str, char c){int count = 0;for(int i=0; i < str.length(); i++){ if(str.charAt(i) == c) count++;}return count;} Write a general Java method, isValidAge, that receives an age, returns true if the age is between 18 and 40 inclusive, returns false otherwise. public static boolean isValidAge(int anAge) Write a general Java method - isValidId. The Method receives an id (as a String) and returns true if the id is valid. Valid ids are 9 chars long, and ALL digits only.method signature: public static boolean isValidId(String aId) public static boolean isValidId(String str) Write a general Java method, getAccountType, the method receives an account number(String) returns 1 if the given account number has a 'C' as its first and second characters, returns 2 if the given account number has an 'M' as its first and second characters, otherwise returns a 0.method signature: public static int getAccountType(String accountNumber)Be sure to test for an accountNumber with fewer than 2 characters, if received, returns a 0. public static int getAccountType(String accountNumber) Order of magnitudea) for(k=0; k<n; k=k+2){print k;for(index = n; index > 0; index --){print k, index}} n^2 Order of magnitudeb) k=n;while(k > 0){k = k/2;if(k%2 ==0)print k} lgn Give a signature for the method doCrazyMath()public static void main(String [] args){String str1 = "Silly Strihg";String str2 = "Crazy String";int [] list = new int [50];Scanner scan = new Scanner(System.in);int num1 = 300;int num2 = 44;double v1 = 0.0005;double v2 = 150.27;char ch1 = 'A';char ch2 = '9';boolean res1 = true;boolean res2 = false;v2 = MyMethods.doCrazyMath(num1, ch2, v1);res1 = MyMethods.findAWayOut(ch1, str2);MyMethods.printCrazyOutput(str1, v2, list);ch2 = MyMethods.makeDecision(str2, num2);str2 = str2.toLowerCase();} public static int doCrazyMath(int num1, char ch2, double v1) Give a signature for the method findAWayOut()public static void main(String [] args){String str1 = "Silly Strihg";String str2 = "Crazy String";int [] list = new int [50];Scanner scan = new Scanner(System.in);int num1 = 300;int num2 = 44;double v1 = 0.0005;double v2 = 150.27;char ch1 = 'A';char ch2 = '9';boolean res1 = true;boolean res2 = false;v2 = MyMethods.doCrazyMath(num1, ch2, v1);res1 = MyMethods.findAWayOut(ch1, str2);MyMethods.printCrazyOutput(str1, v2, list);ch2 = MyMethods.makeDecision(str2, num2);str2 = str2.toLowerCase();} public static boolean findAWayOut(char ch1, string str2) Give a signature for the method printCrazyOutput()public static void main(String [] args){String str1 = "Silly Strihg";String str2 = "Crazy String";int [] list = new int [50];Scanner scan = new Scanner(System.in);int num1 = 300;int num2 = 44;double v1 = 0.0005;double v2 = 150.27;char ch1 = 'A';char ch2 = '9';boolean res1 = true;boolean res2 = false;v2 = MyMethods.doCrazyMath(num1, ch2, v1);res1 = MyMethods.findAWayOut(ch1, str2);MyMethods.printCrazyOutput(str1, v2, list);ch2 = MyMethods.makeDecision(str2, num2);str2 = str2.toLowerCase();} public static int printCrazyOutput(String str1, double v2, list) Give a signuature for the method makeDecision()public static void main(String [] args){String str1 = "Silly Strihg";String str2 = "Crazy String";int [] list = new int [50];Scanner scan = new Scanner(System.in);int num1 = 300;int num2 = 44;double v1 = 0.0005;double v2 = 150.27;char ch1 = 'A';char ch2 = '9';boolean res1 = true;boolean res2 = false;v2 = MyMethods.doCrazyMath(num1, ch2, v1);res1 = MyMethods.findAWayOut(ch1, str2);MyMethods.printCrazyOutput(str1, v2, list);ch2 = MyMethods.makeDecision(str2, num2);str2 = str2.toLowerCase();} public static char makeDecision makeDecision(String str2, int num2) scan is an instance of a Scanner (true or false?) True num1 is a primitive data type? (true or false?) True str1 would be considered a complex data type (true or false?) True str2.toUpperCase(); this method modifies/changes str2 (true or false?) False the method toLowerCase() is called an instance method (true or false?) True

1

Main memory is known as RAM True Any piece of data that is store in a computer's memory must be stored as binary numbers True Images like the ones created with your digital camera cannot be stored as binary numbers False machine language is the only language that a cpu understands True an interpreter is a program that both translates and executes the instructions in a high level language program True a syntax error does not prevent a program from being compiled and executed False word processing programs spreadsheet programs email programs web browsers and games are all examples of utility programs False programmers must be careful not to make syntax errors when writing pseudocode programs True in a math expression, multiplication and division take place before addition and subtraction True variable names can have spaces in them False in pyhton, the first character of a variable name cannot be a number True if you print a variable that has not been assigned a value, the number 0 will be displayed False 00:0301:42 Upgrade to remove ads Only $35.99/year What does a professional programmer usually do first to gain an understanding of a problem Customer What is pseudocode fake codeInformal language that has no syntax rule Computer programs usually perform what three steps 1. Input is received2.Some process is performed on the input3. Output is produced if a math expression adds a float to an int what will the data type of the result be float data type what is the difference between floating point and integer division Floating point division, /, - returns the output in floating data type. It gives the result in decimal places.Integer division, //, - returns the output in integer value. It ignores the decimal place value. a conditioned controlled loop always repeats a specific number of times False the while loop is a preset loop True it is not necessary to initialize accumulator variables False in a nested loop, the inner loop goes through all of its iterations for every single iteration of the outer loop True write a while loop that lets the user enter a numbermultiplied by 10 and the result assigned to a variable named productthe loop should iterate as long as product is less than 100 def main():product = 1while product < 100:num = float(input('Enter number: '))product = num * 10print('Total: ',product)main() function named times_tenaccept an argumentdisplay the product of its argument multiplied times 10 def times_ten(x):return x * 10retValue = times_ten(5)print(retValue)


Kaugnay na mga set ng pag-aaral

Missed Ch. 21: The Immune System

View Set

AP Gov Extreme Final Study Guide (1rst Semester) (Quizzes + Tests)

View Set

Chapter 10: E-Commerce Unique Features

View Set

Chapter 10 - Honors World History Short Answers

View Set

Chapter 3 Quiz: Medical, Legal, and Ethical Issues

View Set

Quiz 2 Music 101 Loyola Chp: 4,5

View Set