ComProg 2 Midterms

0.0(0)
studied byStudied by 361 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/59

flashcard set

Earn XP

Description and Tags

Includes: Quiz 1 (Methods), Quiz 1 Retake, Quiz 2 (Classes)

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

60 Terms

1
New cards
term image

error

2
New cards
term image

Space

3
New cards
term image

Hello Politics 90-yrs old. I am in Queens

4
New cards
term image

error

5
New cards
term image

error

6
New cards
term image

aLEJANDRO

7
New cards
term image

error

8
New cards
term image

error

9
New cards
term image

error

10
New cards
term image

error

11
New cards
term image

error

12
New cards
term image

true

13
New cards
term image

3.0

14
New cards
term image

In the beginning.In the end.

15
New cards
term image

error

16
New cards
term image

1.0

17
New cards
term image

1.0

18
New cards
term image

error

19
New cards
term image

In the beginning.In the middle.In the end.

20
New cards
term image

5

21
New cards
term image

false

22
New cards
term image

error

23
New cards
term image

Hidden

24
New cards
term image

1.0

25
New cards
term image

Hi Ab

26
New cards
term image

error

27
New cards
term image

1728.0

28
New cards
term image

true

29
New cards
term image

error

30
New cards
term image

revealed

31
New cards
term image

Hello dragon kg.75.1

32
New cards
term image

error

33
New cards
term image

error

34
New cards
term image

Hello Hello Hello Hello

35
New cards
term image

Alejandro de JuanAlejandr.

36
New cards
term image

0.0

37
New cards
term image

error

38
New cards
term image

error

39
New cards
term image

2

40
New cards
term image

error

41
New cards

Assume that you have a program that has 2 files: main.java and Person.java. main is the main class where the program starts, and the Person is an additional class for the program.

Person has 3 attributes: name, age, and address. It also has a default constructor, setters and getters for the fields. If in the main method of the main class we create an object of Person that has an identifier of person, what should be the line of code that will declare and instantiate that object?

Person person = new Person();

42
New cards

You are presented with a family of classes: Person, Student, and Staff.

Person has 2 attributes namely a String name and String address. This class also has the default constructor and another one that accepts 2 arguments: String name and String address in that sequence.

Student is a subclass of Person and has 1 attribute being the String studentId. It has the default constructor for the class and another one that accepts 3 arguments: String studentId, String name, and String address in that sequence.

Staff is a subclass of Person also and has 1 attribute being the float salary. There is no constructor stated on this class as well as no setters and getters for the local attribute.

Given the situation, if an object of Staff called steff were to have its attributes be updated such that its salary will be 50.05, what must be the line of code that we need to do such a thing?

steff.salary = 50.05f;

43
New cards

You are presented with a family of classes: Person, Student, and Staff.

Person has 2 attributes namely a String name and String address. This class also has the default constructor and another one that accepts 2 arguments: String name and String address in that sequence.

Student is a subclass of Person and has 1 attribute being the String studentId. It has the default constructor for the class and another one that accepts 3 arguments: String studentId, String name, and String address in that sequence.

Staff is a subclass of Person also and has 1 attribute being the double salary. There is no constructor stated on this class but has setters and getters for the local attribute.

Given that situation, if in the main method of the main class, what must be the line of code I need if I want to declare and instantiate an object of Student named stud that has the name of Alejandro, address of Davao, and Id number of 5555?

Student stud = new Student("5555", "Alejandro", "Davao");

44
New cards

60.0

45
New cards
<p></p>

The Juice you are drinking is called ZESTO and it is 59.00 Fahrenheit cold. This juice is quite good since it has no pulp

46
New cards

LIGHT

47
New cards
term image

Mr. Toriyama is bringing his pet Son Goku 15-yrs old to the park.

48
New cards
term image

We have here a 10-yrs old blue parrot brought by oud named SKY.

49
New cards

Assume that you have a program that has 2 files: main.java and Person.java. main is the main class where the program starts, and the Person is an additional class for the program.

Person has 2 private attributes: String name and String age. It also has one more attribute being an integer yrLevel. It has a default constructor, setters and getters for the private fields. If in the main method of the main class we have an object of Person that has an identifier of pers, what should be the line of code that we need if we got an input from the user using JOptionPane that has a prompt of "Enter year level:" and we assign that to the object's yrLevel?


pers.yrLevel =  Integer.parseInt(JOptionPane.showInputDialog(“Enter year level:”));

50
New cards

You are presented a program that has 2 files: main and Animal. The Animal class has 2 private attributes: String kingdom and double lifespan. The Animal class also has no explicit constructors defined in it, but it does have setters and getters for the field attributes.

In the main method of the main class, an object named animal has been declared as an Animal object and instantiated as an Animal. If I were to mutate the kingdom attribute of that object into the value mammal, what must be the line of code that I must write?

animal.setKingdom(“mammal”);

51
New cards

Assume that you have a program that has 2 files: main.java and Person.java. Main is the main class where the program starts, and the Person is an additional class for the program.


Person has 2 private attributes: name and address. It also has a default constructor, setters, and getters for the fields. If in the main method of the main class we create an object of the Person that has an identifier of person1, what should be the line of code that will display the address in the console?

System.out.println(person1.getAddress());

52
New cards

You are presented with a Food class. In this class, you have 2 private attributes: String food and double calories. There is the default constructor, as well as getters and setters for all the fields.

If we were to declare and instantiate an object of Food named foo, what must be the line of code to do so in the main method?

Food foo = new Food();

53
New cards

Given a Person class with 3 fields: String name, String age, and String address. There are no explicit constructors dictated in the class nor are there any setters and getters for the fields.

What must then be the code if we were to assign the age field of an object of Person named pers with the value 100.

pers.age = “100”;

54
New cards

You are presented with a family of classes: Person, Student, and Staff.

Person has 2 attributes namely a String name and String address. This class also has the default constructor and another one that accepts 2 arguments: String name and String address in that sequence.

Student is a subclass of Person and has 1 attribute being the String studentid, It has the default constructor for the class and another one that accepts 3 arguments: String studentid, String name, and String address in that sequence.

Staff is a subclass of Person also and has 1 private attribute being the float salary. There is no constructor stated on this class but has setters and getters for the local attribute.

Given the situation, if an object of Staff called steff were to have its attributes be updated such that its salary will be 100.1, what must be the line of code that we need to do such a thing?


steff.setSalary(100.1f);

55
New cards

You are presented a family of classes: Drink, Wine, Juice, and Beer. Drink has 2 private fields: String name and integer liters. It also has the default constructors and another that accepts the field values name and liters in that sequence. There are setters for the fields.

The Wine class extends the Drink class and has 1 private field: String taste. It has the default constructor and another that accepts the field values taste, name, and liters in that sequence. There are setters and getters for the local field.

The Juice class extends the Drink class and has 2 private fields: String brand and boolean hasPulp. It doesn't have any explicit constructors dictated but it does have setters and getters for the local fields.

The Beer class extends the Drink class and has 1 field: String quality. It also doesn't have any constructors made for it.

Given that situation, what must be the line of code we need in the main method if we were to mutate the liters field of an object named dri of the Drink class? The value we pass as argument comes directly from a JOptionPane input dialog box which prompts the user "enter liters:".


dri.setLiters(Integer.parseInt(JOptionPane.showInputDialog("enter liters:")));

56
New cards

Assume that you have a program that has 2 files: main.java and Person.java. main is the main class where the program starts, and the Person is an additional class for the program.

Person has 2 private attributes: String name and String age. It also has one more attribute being a String yrLevel. It has a default constructor, setters and getters for the private fields. If in the main method of the main class we have an object of Person that has an identifier of pers, what should be the line of code that we need if we got an input from the user using JOptionPane that has a prompt of "Enter year level:" and we assign that to the object's yrLevel?

pers.yrLevel =  JOptionPane.showInputDialog(“Enter year level:”);

57
New cards

You are presented a family of classes: Drink, Wine, Juice, and Beer. Drink has 2 private fields: String name and double liters. It also has the default constructors and another that accepts the field values name and liters in that sequence.

The Wine class extends the Drink class and has 1 private field: String taste. It has the default constructor and another that accepts the field values taste, name, and liters in that sequence. There are setters and getters for the local field.

The Juice class extends the Drink class and has 2 private fields: String brand and boolean hasPulp. It doesn't have any explicit constructors dictated but it does have setters and getters for the local fields.

The Beer class extends the Drink class and has 1 field: Integer quality. It also doesn't have any constructors made for it.

Given that situation, what must be the line of code we need in the main method if we were to only declare a Beer object named bee?


Beer bee;

58
New cards

You are presented a program that has 2 files: main and Animal. The Animal class has 2 attributes: String kingdom and double lifespan. The Animal class also has no explicit constructors defined in it, but it does have getters for the field attributes.

In the main method of the main class, an object named animal has been declared as an Animal object and instantiated as an Animal. If I were to assign the kingdom attribute of that object into the value invertebrate, what must be the line of code that I must write?

animal.kingdom = “invertebrate”;

59
New cards

You are presented with a family of classes: Person, Student, and Staff.

Person has 2 attributes namely a String name and String address. This class also has the default constructor and another one that accepts 2 arguments: String name and String address in that sequence.

Student is a subclass of Person and has 1 attribute being the String studentid. There is no constructor stated on this class.

Staff is a subclass of Person also and has 1 attribute being the double salary. There is no constructor stated on this class but has setters and getters for the local attribute.

Given that situation, if in the main method of the main class, what must be the line of code we need if we were to declare and instantiate a Student object named stud?

Student stud = new Student();

60
New cards

You are presented a family of classes: Drink, Wine, Juice, and Beer. Drink has 2 private fields: String name and String liters. It also has the default constructors and another that accepts the field values name and liters in that sequence. There are setters for the fields.

The Wine class extends the Drink class and has 1 private field: String taste. It has the default constructor and another that accepts the field values taste, name, and liters in that sequence. There are setters and getters for the local field.

The Juice class extends the Drink class and has 2 private fields: String brand and boolean hasPulp. It doesn't have any explicit constructors dictated but it does have setters and getters for the local fields.

The Beer class extends the Drink class and has 1 field: String quality. It also doesn't have any constructors made for it.

Given that situation, what must be the line of code we need in the main method if we want to declare and instantiate an object of wine named wine with the values Carlo Rosi for the name, 1 for the liters, and sweet-sour for the taste?

Wine wine = new Wine(“sweet-sour”, ”Carlo Rosi”, ”1”);