Question

In: Computer Science

1) Which answer is the best description of “parsing”. (3pts)A. Converting a double to an...

1) Which answer is the best description of “parsing”. (3pts)

A. Converting a double to an int with the (int) cast operator

B. Reading a file of textual records and writing them to a new file

C. Taking apart and converting text data to other forms

D. Performing a database query

2) What is an advantage of encapsulation? (3 pts)

A.Shields the data of the class

B.Can control access via an API

C.Easier to test

D. Improves maintainability and reusability

E. All of the above

3) What is the difference between a class and an instance of a class? (3pts)

A. A class lists the methods and the instance lists the state variables.

B. A class is a template for state variables and methods in an object. An instance of a class is a specific object of the class created by the new command.

C.A class has to have at least one instance.

D.A class does not have a .java file but an instance does.

E. Every instance of a class has a different API.

4) What is an example of “tokenizing”? (3pts)

A.Creating an array and assigning values with a Scanner loop

B. Splitting a String into an array of Strings using a delimiter (e.g., “\t”)

C. Iterating through the characters of String variable

D.Using String.substring to isolate a particular part of a string

E.Converting a string to uppercase.

5) Which of these statements declares an ArrayListthat contains only Student objects(objects that are instances of Student)?(Assume no subclassing) (3pts)

A. ArrayList myStudentList = new ArrayList();

B. ArrayListmyStudentList = new ArrayList();

C. ArrayListmyStudentList = new ArrayList();

D. ArrayListmyStudentList = new ArrayList();

E. ArrayListmyStudentList = new ArrayList();


Solutions

Expert Solution

1) The correct answer should B)

Explanation:

A) is wrong as converting from one datatype to another is known as typecasting.

C) and D) are wrong as querying a database or converting text from one form to another is also not parsing.

B) is correct as reading or writing files can be said as parsing.

2) The correct answer is E

Explanation:

Encapsulation has many advantages like the reusaility of code as mentioned above.

Also, the shielding of the private variable from the outside world and others like Maintanibiity and testing.

So all of the above are correct

3) The correct answer is B)

Explanation:

A class is just a template defined by us which says that, whatever object would be created using that class will follow the template we created.

The objects are created using the new keyword

We can create as many obects we want using the new keyword

4) The correct answer is B)

Explanation:

Tokenizing refers to splitting anything into multiple parts.

So, when we break a String into multiple Strings based on \t, this can be said as tokenizing.

5) The correct answer is C)

Explanation:

In the option C declaration, Student class is mentioned already there.

That means, if no subclassing is there, only the objects of the Student class can be put inside that Array List.

SO, this is the correct option.


Related Solutions

1. Which of the following is the best description of a genome? a. All of the...
1. Which of the following is the best description of a genome? a. All of the genes of an organism b. A sequence of DNA bases that code for a particular protein c. A single molecule of DNA d. A duplicated chromosome formed by DNA replication 2. The end result of mitosis is a. two cells, each with half the number of chromosomes as the mother cell. b. two cells, each with twice the number of chromosomes as the mother...
Which is the best description of GDP
Which is the best description of GDP
Which description best identifies the unique attributes of connective tissue? Which description best identifies the unique...
Which description best identifies the unique attributes of connective tissue? Which description best identifies the unique attributes of connective tissue? A. Connective tissues, unlike other tissues, lack blood vessels and blood. B. Connective tissues transmit signals from one part of the body to another. C. Connective tissue is characterized by an extracellular matrix. D. Connective tissues are hard and inflexible, whereas soft, flexible structures of the body are made up of other tissue types.
Which description best depicts a liquid?
Which description best depicts a liquid?
Which of the following is the best description of metagenomics?
Which of the following is the best description of metagenomics?The process of assembling contigs into scaffolds to identify chromosomesThe process of identifying duplicated genes using genome sequences.The process of comparing genes across species to construct a phylogenetic tree.The process of sequencing bacterial DNA to identify the bacteria present in a sample.The process of converting RNA into cDNA to measure gene expression.
which is the best description of insect wings?
which is the best description of insect wings?A) they are homologous to insect mouth partsB) they are homologous to vertebrate front legsC) they are homologous to vertebrate hind legsD) they are extensions of current insect limbsE) they are cuticular extension of the epidermis
Which of the following provides the best description of depolarization?
Which of the following provides the best description of depolarization?
Which is the best description of the problem of conformity, forEmerson?
Which is the best description of the problem of conformity, for Emerson?
Which is the best description of the problem of conformity, forEmerson?
Which is the best description of the problem of conformity, for Emerson?
1. Which reagent would be best for converting D-fructose to D-mannitol? 2. What determines whether or...
1. Which reagent would be best for converting D-fructose to D-mannitol? 2. What determines whether or not a sugar is reducing?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT