+1(978)310-4246 credencewriters@gmail.com
  

UnauthorizedCSci 1933 Week 2 Study Questions
These are a few self-test questions to check your absorption of the material covered during the first
two weeks (or so) of class.
1. Java uses static strong typing, and Python uses dynamic strong typing.
a. How is dynamic different from static?
b. How does the static/dynamic typing affect how you program in Java/Python?
c. How is strong typing different from weak typing?
2. What is the difference between compiling and interpreting?
3. Java and Python use a similar translation process from source to machine code. Describe it.
4. How do several mutually exclusive conditions typically translate into Java conditionals, compared
with non-exclusive conditions?
5. How do variables declared within a method differ from those declared directly within a class?
6. What does the keyword “static” do in front of a method declaration?
7. Java class attributes should generally not be public. Why? If public access (both read and write)
to a attribute is desired, how should that be accomplished?
8. What is the difference between declaring a variable and initializing a variable?
9. If an identifier starts with an upper case letter, but the rest of the letters are lower case, the
identifier is likely a symbol for what?
10. All Java executable code must be contained within a _________.
11. All Java methods must be contained within within a _________.
12. Why is main() static?
13. All Java programs must have a main() method contained within a ________ ________ named
the same as the file in which it is contained, except that the file will have a .java suffix.
14. Explain how to compile and run the program MyProgram.java from the command line.
15. Based on Java conventions, in the statement: System.out.println(“Hello”);
What is System?
What is out?
What is println()?
16. What is embedded software? Why was Java originally envisioned as an embedded systems
language?
17. If an instance method is being designed to perform a binary operation on two instances of a
class, how many parameters should it typically have? Explain.
18. What does toString() do? What should you include in a toString() method?
19. What does equals() do compared with == ?
20. What is the difference in the the contents of memory allocated for a primitive type variable (such
as int) and an object variable such Complex4?
21. Write a complete class to represent a Rectangle. Include constructors, attributes, selectors,
operators: area(), perimeter(), addArea(Rectangle), addPerimeter(Rectangle), toString() and
equals(). Write a main() test driver to validate your Rectangle class.
CSci 1933 Week 4 Study Questions
CSci 1933 Study Question Set 2
These are a few self-test questions to check your absorption of the material covered during the third
and fourth weeks of the course.
1. What is call-by-value (or pass-by-value)? Describe how it works.
2. What languages use call-by-value?
3. Why is it that arrays passed to a method can be mutated by the method, but primitive data
like int and double cannot be mutated by a method?
4. Write a method called arrayInit(int[] a, int initValue) to initialize all the elements of an integer
array, a, to initValue. What return type should arrayInit() have?
5. Write a method called reset(int[] a) which will reset all values within array, a, which are
outside the range 0..100 (inclusive) to -1. Does this method need to return anything? Explain.
6. Write a method called make2DArray(int nRows) to create and return a two-dimensional “ragged”
array initialized to all zeroes that looks like this:
Row 0: 0
Row 1: 0 0
Row 2: 0 0 0
Row 3: 0 0 0 0

Row n-1: 0 0 0 0 … 0
In other words, the first “row” is of length 1, the second “row” of length 2,…, and the (n-1)th “row” is
length n-1.
7. What does “new” do?
8. What is a default constructor?
9. Why should class variables always be private, even if we supply public accessor methods for
them?
10. Write the code needed to find and print the length of this array.
int[] intArray = {1, 2, 3, 4, 5}
11. Write a complete method to reverse the contents of an array of ints. Name your method
reverse().
12. Assume we have created a Rational class to represent rational numbers. How many
parameters should the following instance methods take in?
• clone()
• copy()
• add()
• inverse()
Briefly explain.
13. What is the difference between cloning and copying?
14. Suppose a class variable is declared as “static.” How will it be different from a variable that
does not have the “static” designator?
15. What is method and constructor overloading?
16. What does the equals() method (as inherited from Object) do?
17. Write a recursive method to find and return the smallest element in an array of ints. Name your
method getSmall(). What parameters should your method take in?
18. Write the same method above but make it iterative using a loop.
19. Will == determine if two Rational number objects are equal? Explain.
20. What is an automatic variable? Are automatic variables initialized for you? Why are they called
“automatic?”
21. How do method variables and formal parameters differ? Is it safe to say that method variables
and formal parameters are almost the same? Why?

Purchase answer to see full
attachment

  
error: Content is protected !!