New User Special Price Expires in

Let's log you in.

Sign in with Facebook


Don't have a StudySoup account? Create one here!


Create a StudySoup account

Be part of our community, it's free to join!

Sign up with Facebook


Create your account
By creating an account you agree to StudySoup's terms and conditions and privacy policy

Already have a StudySoup account? Login here


by: Miss Willie Koch

Algorithms&DataStrucII CSC1052

Miss Willie Koch
GPA 3.54


Almost Ready


These notes were just uploaded, and will be ready to view shortly.

Purchase these notes here, or revisit this page.

Either way, we'll remind you when they're ready :)

Preview These Notes for FREE

Get a free preview of these Notes, just enter your email below.

Unlock Preview
Unlock Preview

Preview these materials now for free

Why put in your email? Get access to more of this material and other relevant free materials for your school

View Preview

About this Document

Class Notes
25 ?




Popular in Course

Popular in ComputerScienence

This 6 page Class Notes was uploaded by Miss Willie Koch on Wednesday October 28, 2015. The Class Notes belongs to CSC1052 at Villanova University taught by CatherineHelwig in Fall. Since its upload, it has received 17 views. For similar materials see /class/230566/csc1052-villanova-university in ComputerScienence at Villanova University.


Reviews for Algorithms&DataStrucII


Report this Material


What is Karma?


Karma is the currency of StudySoup.

You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 10/28/15
CSC 1052 Review Name Sect 1 Is it possible for a method ofa class to call another method in the same class A No B Yes but only public methods C Yes but only private methods D Yes both public and private methods can be called within a method of the same class 2 Can two different classes contain methods with the same name A No B Yes but only if the two classes have the same name C Yes but only ifthe main program does not create objects of both kinds D Yes this is always allowed 3 What is the common pattern of class definitions that we use in JAVA A Methods and instance variables are both private B Methods are private and instance variables are public C Methods are public and instance variables are private D Methods and instance variables are both public 4 What is the primary purpose ofa constructor A To allow multiple classes to be used in a single program B To copy an actual argument to a method39s parameter C To initialize each object as it is declared D To maintain a count of how many objects ofa class have been created 5 The String class overrides the equals method ofthe Object class What happens when an expression 51 equals 52 is evaluated for two String objects A The expression is true ifs1 and s2 refer to the same object B The expression is true if s1 and s2 refer to objects with the same values C Compiler error D Run time error 6 public class Quiz private double score public int F method called F public static int G method called G Where could the assignment score1 0 appear for the instance variable score A Both F and G can carry out the assignment B F can carry out the assignment but not G C G can carry out the assignment but not F D Neither F nor G can carry out the assignment 7 An interesting method ofclass object is equals0bject 011 Given the following declarations 1 Boat tug new Baat456 red 45 2 Student Sum new StudentquotSam 19233455 3 Boolean istme tugeqnulsmm 4 Sum tug What is the result of line 3 line 4 The Coin class as de ned in Chapter 4 consists ofa constructor and methods ip getFace and toString The method getFace returns an int 0 if the last ip was a Heads and 1 if the last ip was a Tails The toString method returns a String equal to Heads or Tails depending on the result ofthe last ip 8 What does the following code compute int num 0 forintj 0j lt 1000 j c ip ifcgetFace 0 num double value double num 1000 a the number ofHeads ipped out of 1000 ips b the number ofHeads ipped in a row out of 1000 ips c the percentage of heads ipped out of 1000 ips d the percentage oftimes neither Heads nor Tails were ipped out of 1000 ips e nothing at all 9 What value does total represent compute int num 0 total 0 last 1 while num lt 3 c ip total ifcgetFace 0 num The number of ips it takes to get 3 Heads ipped The number of ips it takes to get 3 Heads ipped in a row The number of ips it takes to get 2 Heads ipped in a row 3 times The number of ips it takes to get 3 Heads ipped in a row twice The number of ips it takes to get 9 Heads ipped 3353 10 I have an array named data which contains n integers I want to print all ofthe numbers starting at data0 BUT ifthe number 42 occurs then I want to stop my printing just before the 42 without printing the 42 Here is most of my for loop to accomplish my goak for i 0 i Systemout printlndata i What is the correct way to ll in the blank Ifthere is more than one correct answer please select E A datai 42 ampamp i lt n B datai 42 H i lt n C i lt n ampamp datai 42 D i lt n H datai 42 E More than one ofthe above answers is correct 11 Which ofthe following could be used to instantiate a new Student s1 a Student s1 new Student Scott Frey Electrical Engineering 3 33 b s1 new Student c Student s1 quotJane Doequot quotComputer Sciencequot 333333 d More that one ofthe above 12 Assume that another method has been defined that will compute and return the student s gpa It is defined as public double getGPA Given that s1 is a student which of the following would properly be used to get s1 s gpa double s1 getGPAdouble gpa double s1toString double gpa s1getGPA double s1getGPAO getGPAs1 83853 For questions 13 15 use the following class definition public class Swapper private int X private String y public int z public Swapperint a String b int c x a y h z c public String swap int temp X x z z temp return y public String toString if x lt z return y else return quotquot x z 13 Ifthe code Swapper s new Swapper0 quothelloquot 0 is executed followed by stoString what value is returned from stoString a quothelloquot b quothe11000quot c quot00 d quot0 e 0 14 Which ofthe following criticisms is valid about the Swapper class a The instance data x is visible outside of Swapper b The instance data y is visible outside of Swapper c The instance data z is visible outside of Swapper d All 3 instance data are visible outside of Swapper e None ofthe methods are visible outside of Swapper 15 Ifwe have Swapper r new Swapper 5 quotnoquot 10 then rswap returns which of the following a nothing quotnoquot c quotn0510quot d quot15 16 What does the following method do 1 7 public boolean mysteryString a String b return atoLowerCase charAt0 btoLowerCase charAt0 returns true if the two Strings start with the same character ignoring case and false otherwise returns true ifthe two Strings are lowercase and false otherwise Returns true if the first character of each string is lowercase None ofthe above w v n EVE For the following questions assume x and y are String variables with x quotHelloquot and y null a The result of x y is c a syntax error a runtime error e x being set to the value null b The result of x length y length is a 0 b 5 c 6 d 10 e a thrown exception c If the operation y quotHelloquot is performed then the result of x y is a true b false c x and y becoming aliases d x being set to the value null e a runtime error d If the operation y x is performed then the result of x y is a true b false c x being set to the value null while y retains the value quotHelloquot d y being set to the value null while x retains the value quotHelloquot e x being set to y which it is already since y x was already performed TF 18 a Static methods can use instance variables b Each object created from a class has a copy ofall static and non static variables Free Form 19 We have two arrays ofintegers initialized to int listl 11123355 int list2 13449977 Name one way to make list2 be an alias oflistl 20 When is it appropriate to implement a static method Give a example as part ofyour answer 21 Describe what the following code does What is its output char A new char3 char B int i for i o ilt A length i Ai f B A Systemoutprintln A3 A3 B3 B1 n Systemoutprintln A1 A1 B1 p A Pg gy39PP 22 Draw a memory map for the above code including the changes in the values Arrays 1 Create an array of Students objects with 5 elements 2 Create an array of CD objects with 10 elements Put a CD into the 3rd position in the array 3 Create an array of Customer objects with 500 elements Put one customer into the fifth position in the array 4 Which ofthe following are correct int primes 2 4 5 7 6 Double times 1147 1204 1172 1388 int scores new double30 int primes 2 3 4 6 char grades 39a39 39b39 quotcquot 39d39 char grades new character 500 5 Do two ofthe following methods 1 powers of2 starting with 2 The method takes no parameters and doesn39t return anything Write a method called sum100 that returns the sum ofthe integers from 1 to 100 Write a method called sumRange that accepts two integer parameters that represent a range You may assume the first parameter is less than or equal to the second The method should return the sum ofthe integers in that range Write a method called maXOfI wo that accepts two integer parameters and returns the larger ofthe two Write a method called larger that accepts two floating point parameters oftype double and returns true ifthe first integer parameter is greater than the second and false otherwise Write a method called countA that accepts a String parameter and returns the number oftimes the letter A is found in the string Write a method called evenlyDivisible that accepts two integer parameters and returns true ifthe first parameter is evenly divisible by the second or vise versa and false otherwise Write a method called average that accepts three integer parameters and returns their average as a floating point value Write a method called multiConcat that takes a String and an integer as parameters and returns a String that is the parameter string concatenated with itselfn number oftimes where n is the second parameter For example ifthe parameters are hi and 4 the return value is hihihihi


Buy Material

Are you sure you want to buy this material for

25 Karma

Buy Material

BOOM! Enjoy Your Free Notes!

We've added these Notes to your profile, click here to view them now.


You're already Subscribed!

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

Why people love StudySoup

Bentley McCaw University of Florida

"I was shooting for a perfect 4.0 GPA this semester. Having StudySoup as a study aid was critical to helping me achieve my goal...and I nailed it!"

Jennifer McGill UCSF Med School

"Selling my MCAT study guides and notes has been a great source of side revenue while I'm in school. Some months I'm making over $500! Plus, it makes me happy knowing that I'm helping future med students with their MCAT."

Steve Martinelli UC Los Angeles

"There's no way I would have passed my Organic Chemistry class this semester without the notes and study guides I got from StudySoup."


"Their 'Elite Notetakers' are making over $1,200/month in sales by creating high quality content that helps their classmates in a time of need."

Become an Elite Notetaker and start selling your notes online!

Refund Policy


All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email


StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here:

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to

Satisfaction Guarantee: If you’re not satisfied with your subscription, you can contact us for further help. Contact must be made within 3 business days of your subscription purchase and your refund request will be subject for review.

Please Note: Refunds can never be provided more than 30 days after the initial purchase date regardless of your activity on the site.