Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1.Why do we use access specifiers? a)To ensure that only certain kinds of data g

ID: 3907206 • Letter: 1

Question

1.Why do we use access specifiers?

a)To ensure that only certain kinds of data get stored.

b)Prevent other programmers from using the object.

c)Informs other programmers of the intended abstraction.

d)Keep hackers out of our programs.

2.Why do we allocate memory on the heap?

a)So that it is not deallocated when the declaring function ends.

b)So that we can use a pointer to access it.

c)Because we have to use the new function to create a pointer to an object.

d)We have no other options.

3.Why do we parse the input tokens prior to interpretation/code emission?

a)The parser splits the input string on whitespace or other predefined symbols.

b)The parser ensures semantic correctness.

c)The parser ensures correct behavior.

d)The parser eliminates ambiguity by forcing a specific grammar.

4. What is declarative programming?

a) Programming that specifies an explicit sequence of commands to solve a problem.

b) Programming that specifies the result you want, not how to get it.

c) Programming with nested control structures with no need for goto/jump

d) Programming that allows for easily calling other code sections and returning correctly.

5.What is structured programming?

a) Programming that specifies an explicit sequence of commands to solve a problem.

b) Programming that specifies the result you want, not how to get it.

c) Programming with nested control structures with no need for goto/jump

d) Programming that allows for easily calling other code sections and returning correctly.

6. True/False (Two points each)

a) The type of a variable is always determined during tokenization. True   /   False

b) The purpose of Tokenizers are to check grammar.                                      True   /   False

c) How do objects become wealthy?                                                               Inheritance

(20 pts / 4 pts each) Free Response. Answer each of the following to the best of your ability. (50 words or less)

1. What is a static method?

2. What OOP mechanism does C++ support that Java lacks?

3. Which programming paradigms does Lua support?

4.Why do we use classes and OOP?

5.What is imperative programming?

(20 pts) Write the functions that do the following in each language or answer the question.

(8 pts each language) Write the function “F”. Consider the implementation below.

(2 pts) What does F(7) return? __________________

(2 pts) What does this function compute? ________________

Lua implementation

     function F(x):

         >

          two = 1

          for i =1,x do

               three = one + two

              >

               two = three

          end

          return one

     end

a) C

Explanation / Answer

1.What is a static method?

Answer:

a static method is a method that belongs to a class rather than an instance of a class. The method is accessible to every instance of a class, but methods defined in an instance are only able to be accessed by that member of a class.

Java allows developers to define static methods, which are available to every instance of a class. In an instance of a class, the methods are able to access both variables in an instance and those belonging to a class, while static methods cannot access instance variables or methods directly. Instead, static methods have to use object reference. The most common use for static methods is to access static variables. They are accessed by the class name and a dot (.) followed by the name of a method. They are declared with the keyword "static" when defining a method. Static methods can be accessed without having to create a new object

4)Answer:

You need to have a class before you can create an object. Objects have properties and methods. ... Object-oriented programming uses a number of core concepts: abstraction, encapsulation, inheritance and polymorphism. These concepts are implemented using classes, objects and methods.

5)Answer:

imperative programming is a programming paradigm that uses statements that change a program's state. In much the same way that the imperative mood in natural languages expresses commands, an imperative program consists of commands for the computer to perform. Imperative programming focuses on describing how a program operates.

The term is often used in contrast to declarative programming, which focuses on what the program should accomplish without specifying how the program should achieve the result

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote