week 2:
GladLibs | |
This is java programming arrays, lists and structured data week 2 quiz answers. you will not need any other answers to solve this java programing questions.You need to know about this java programming course that make you good in learning how to make arrays, lists and structured(object) of data.Quiz, 19 questions | |
1. Question 1 | |
Consider the first version of GladLibs we saw in this lesson, which stores label substitutions in ArrayLists. Assume an ArrayList named wordsUsed will keep track of words used as replacements so no replacement word will be used more than once. The code below was used as part of a program by a learner in the method processWord. The learner's program runs but still results in duplicate words sometimes. | |
String sub = getSubstitute(w.substring(first+1,last)); | |
while (true) { | |
if (wordsUsed.contains(sub)) { | |
sub = getSubstitute(w.substring(first+1,last)); | |
break; | |
} | |
else { | |
wordsUsed.add(sub); | |
} | |
} | |
Which one of the following best explains why this code still returns duplicates sometimes?
the answer is here: | |
If a word is a repeated word, then this code gets another random word and uses that second word without checking to see if it is a repeated word. | |
2. Question 2 | |
Consider the first version of GladLibs we saw in this lesson, which you modified so there would not be duplicate words chosen for the story. Assume an instance variable is used to keep track of the total number of word tags that are replaced. | |
Which one of the following methods is most likely where that variable is updated?
the answer is here: | |
processWord | |
3. Question 3 | |
Consider the class WordFrequencies, which you wrote in an assignment, that can determine facts about words in a file. | |
How many unique words are in the file errors.txt?
the answer is here: | |
3721 | |
4. Question 4 | |
Consider the class WordFrequencies, which you wrote in an assignment, that can determine facts about words in a file. | |
Which word occurs the most often in the file errors.txt? | |
(You should lowercase all words and include the punctuation as part of a word. Thus, “end.” is different than “end”, but “All” is the same as “all”(
the answer is here: | |
of | |
5. Question 5 | |
Consider the class WordFrequencies, which you wrote in an assignment, that can determine facts about words in a file. | |
Find the word that occurs the most often in the file errors.txt. | |
(You should lowercase all words and include the punctuation as part of a word. Thus, “end.” is different than “end”, but “All” is the same as “all”.) | |
How many times does the most common word occur?
the answer is here: | |
609 | |
6. Question 6 | |
Consider the class CharactersInPlay, which you wrote in an assignment, that determines who the characters were in one of Shakespeare’s plays and also how many lines they had. | |
What is the name of the character with the third most speaking parts in the file errors.txt?
the answer is here: | |
ADRIANA | |
7. Question 7 | |
Consider the class CharactersInPlay, which you wrote in an assignment, that determines who the characters were in one of Shakespeare’s plays and also how many lines they had. | |
Find the name of the character with the third most speaking parts in the file errors.txt. How many speaking parts does this person have?
the answer is here: | |
79 | |
8. Question 8 | |
Consider the class CharactersInPlay, which you wrote in an assignment, that determines who the characters were in one of Shakespeare’s plays and also how many lines they had. | |
How many characters in the file errors.txt have at least 10 speaking parts, but no more than 15 speaking parts?
the answer is here: | |
3 | |
9. Question 9 | |
Consider the class you wrote to find out how many times each codon occurs in a strand of DNA based on reading frames. The file dnaMystery2 represents a long strand of DNA. | |
How many unique codons are there if you use a reading frame that starts at position 1?
the answer is here: | |
32 | |
10. Question 10 | |
Consider the class you wrote to find out how many times each codon occurs in a strand of DNA based on reading frames. The file dnaMystery2 represents a long strand of DNA. | |
What is the number of occurrences of the codon that occurs the most often using a reading frame that starts at position 2?
the answer is here: | |
12 | |
11. Question 11 | |
Consider the class you wrote to find out how many times each codon occurs in a strand of DNA based on reading frames. The file dnaMystery2 represents a long strand of DNA. | |
Using a reading frame that starts at position 0, which of the following codons occur 7 times? (Select all that are correct.)
the answer is here: | |
CAG | |
CAA | |
12. Question 12 | |
Consider the class WordsInFiles, which you wrote in an assignment, that determines which words occur in several files, and for each word, which files they occur in. | |
Consider the seven files: caesar.txt, confucius.txt, errors.txt, hamlet.txt, likeit.txt, macbeth.txt, and romeo.txt. | |
How many words are there that each occur in all seven files?
the answer is here: | |
570 | |
13. Question 13 | |
Consider the class WordsInFiles, which you wrote in an assignment, that determines which words occur in several files, and for each word, which files they occur in. | |
Consider the seven files: caesar.txt, confucius.txt, errors.txt, hamlet.txt, likeit.txt, macbeth.txt and romeo.txt. | |
How many words are there that each occur in four of the seven files?
the answer is here: | |
826 | |
14. Question 14 | |
Consider the class WordsInFiles, which you wrote in an assignment, that determines which words occur in several files, and for each word, which files they occur in. | |
Consider the seven files: caesar.txt, confucius.txt, errors.txt, hamlet.txt, likeit.txt, macbeth.txt and romeo.txt. | |
In which file does the word “sea” NOT appear? | |
(Consider only the exact lowercase string "sea". "SEA" or "sea." would be different words.)
the answer is here: | |
likeit.txt | |
15. Question 15 | |
Consider the class WordsInFiles, which you wrote in an assignment, that determines which words occur in several files, and for each word, which files they occur in. | |
Consider the seven files: caesar.txt, confucius.txt, errors.txt, hamlet.txt, likeit.txt, macbeth.txt and romeo.txt. | |
In which of the following files does the word “tree” appear? (Choose all that apply.) | |
(Consider only the exact lowercase string "tree". "TREE" or "tree." would be different words.)
the answer is here: | |
confucius.txt | |
likeit.txt | |
macbeth.txt | |
romeo.txt | |
16. Question 16 | |
Consider the map version of GladLibs where a map is created that maps a category to a list of words in that category. | |
In which method are the individual ArrayLists of words for categories created?
the answer is here: readIt
| |
17. Question 17 | |
Consider the map version of GladLibs where a map is created that maps a category to a list of words in that category. In which method are these individual ArrayLists of words placed into the HashMap?
the answer is here: | |
initializeFromSource | |
18. Question 18 | |
Consider the map version of GladLibs and consider the method totalWordsInMap that returns the total number of words in all the ArrayLists in the HashMap myMap. | |
Which two of the following code possibilities compute this sum of total number of words in the variable sum?
the answer is here: | |
int sum = 0; | |
for (String category : myMap.keySet()) { | |
sum += myMap.get(category).size(); | |
} | |
int sum = 0; | |
for (String category : myMap.keySet()) { | |
ArrayList<String> words = myMap.get(category); | |
sum += words.size(); | |
} | |
19. Question 19 | |
Consider the map version of GladLibs and consider the method totalWordsConsidered that returns the total number of words in the ArrayLists of the categories that were used for a particular GladLib. Assume a private variable of type ArrayList<String> and named categoriesUsed is used to store the unique categories found as the GladLib is created. | |
In which method would we put a category into this ArrayList?
the answer is here: processWord
introduction... About this CourseBuild on the software engineering skills you learned in “Java Programming Solving Problems with Software” by learning new data structures. Use these data structures to build more complex programs that use Java’s object-oriented features. At the end of the course you will write an encryption program and a program to break your encryption algorithm. After completing this course, you will be able to: help you to practice your skills in structured data(arrays, lists and objects) by doing some quiz by week, you need to answer to pass this course. size of program doesn't matter or what type of coding, you just need to know how the language work and what fundamentals do you need to learn to act with it. arrays, lists and structured data are using in many fields. structure need to be built with some data, arraylists, arrays and lists to make a useful program that can be used. testing yourself with quiz or exam, study uploaded chapter and make interview to make sure you can finally work with real world problem, and applying for job(javascript, html, stack, css, csv .....). work with all items, method and class in hours to make good work 1. Read and write data from/to files in ordered list. 2. Solve real world problems involving data files. 3. Perform quantitative analyses of structured data (e.g., finding maximums, minimums, averages). 4. Store and manipulate data in an array or Array List. 5. Combine multiple classes and objects to solve larger problems. 6. Use iterables and collections (including maps) in Java. some task you will learn to solve anther time java programming graph needed to wright with coding. anther courses help you explore high level tools to make development and help any web site developed by adding new features. and computer science is very enjoyable capturing various information, it's like university to you help you practice getting natural job. you can look or search about java programing, and you can choose to start today or not developing android, but you have to make correct decision and discover projects (written specialization, designed content). and now with this course you will begin to learn object oriented language. some reviews: -Actually, before I start this course I had not a good idea about OOP concept such as constructors, HashMap.now I have fair confidence about that. thank you duke university making such an arrangement. -Good and practical training approach to solve real worlds problems. Assignments and quizzes are quite challenging and interesting. Greatly motivates us towards programming and problem solving skills. -The course was pretty challenging (and occasionally frustrating) for a novice programmer, but doable.\n\nI enjoyed the course, and came away with a greater understanding of computers and programming. -The programming exercises are really interesting! They make programming much more fun to study. The lecturers are all great and the lessons are engaging. Enjoyed it greatly! Thank you Duke. | |
Post a Comment
Leave a message