Variable declarations

  1. Declare a variable named numMinutes that holds a 32 bit whole number and is initialized to the value of the integer read from the keyboard (use a print statement to ask the user to enter a whole number).
  2. Declare a variable named numSeconds that holds a 32 bit whole number and is initialized to 60 times the value stored in numMinutes.
  3. Write code that creates a variable name finished that holds the Boolean value true if the value in numSeconds is greater than or equal to 120 and holds false otherwise.  Print to the screen “Finished: ” followed by the value of the variable finished.
  4. Ask the user to enter an integer and store the integer in a variable named number.  Print to the screen “Is multiple of three: ” followed by true if the value in number is a multiple of three, and false otherwise.
  5. Declare two integers named maxAge and curAge and initialize them using values read from the keyboard (include print statements requesting integer values). Write a statement that creates a variable named overLimit that is set to true if the value of curAge is greater than the value of maxAge, and set to false otherwise.  Print to the screen, “Over the Limit:  ” followed by the value of the variable overLimit.
  6. Declare a variable named average and initialized it to the decimal value read from the keyboard (ask the user to enter the value). Write a block of code that sets a Boolean variable named passing to true if average is greater than 65, otherwise sets passing to false.  Print to the screen “Passed: ” followed by the value of the variable passing.
  7. Ask the user to enter a string from the keyboard and store the string in a variable named str.  Print to the screen “Length: ” followed by the length of str.
  8. Replace all of the instances of the character ‘a’ with the character ‘o’ and print the result to the screen.
  9. Declare a variable named idx and initialize it to the index of the first instance of the character ‘e’ in the string str.  Print to the screen “Index: ” followed by the value stored in idx.

Conversions & Declarations

  • Answer all questions in prior reviews.
  • Count from 0 to 20 (base 10) in binary.
  • Convert 250 (in base 10) to base 2.
  • Convert 11001100 (base 2) to a decimal value.
  • Declare a variable named code and initialize it to the character X.
  • Declare a variable named mean and initialize it to the value 80.5.
  • Assume you have the character X saved in a variable named code and 80.5 stored in a variable named mean. Write a print statement using println and the variables to print the following:
    • Code: X, Mean: 80.5
  • Assume you have the character X saved in a variable named code and 80.5 stored in a variable named mean. Write a print statement using printf and the variables to print the following:
    • Code: X, Mean: 80.5
  • Declare a variable named middleName and initialize it with the string of characters “Joe”.
  • Assume you have a variable named middleName that holds a string of characters. Write a statement that prints the length of the String.
  • Assume you have a variable named middleName that holds a string of characters. Write a statement that stores the length of the String in a variable named length.
  • Read an integer from the keyboard and store it in a variable named height.
  • Read a floating point value from the keyboard and store it in a variable named area.
  • Read a string from the keyboard and store it in a variable named title.

Basics

  • Write a program in a class named Welcome that prints to the screen the string of characters “Welcome to the Jungle”.
  • What command can you use to compile the source code file Welcome.java?
  • What command can you use to run the program defined by the class named Welcome?
  • What does CPU stand for?
  • What does RAM stand for?
  • What does it mean for a storage component to be volatile?
  • Which storage components in a computer are volatile and which are non-volatile?
  • When an Operating System starts a program for the user, what resource management object does it create for the running program?
  • Where do executable files (programs) reside when they are being run on a computer?
  • What do programs use to temporarily hold data?
  • Convert the value 110 in base 10 to binary.
  • Convert 10101010 in binary to base 10.
  • What is a bit?
  • How many bits in a byte?
  • How many bytes in a kilobyte, megabyte, and gigabyte?
  • What are the 2 categories of variable types?
  • What are the primitive types?
  • What are the default values of each primitive type?
  • What are the rules for constructing identifiers?
  • What is the general form of an assignment statement?
  • How do you obtain a list of the running processes on a Linux machine?
  • What is the command to terminate process 1234?

AWS, Linux, and Vi

  • What does AWS stand for and what services does it provide?
  • What does VM stand for and what is a VM?
  • What is an Operating System?
  • Who created Linux?
  • What programs provide us a command prompt?
  • What program do we run from the command line in order to connect to our VMs?
  • What is a .pem file?
  • What 3 pieces of information are needed in order to connect to our VM using ssh?
  • What command can you use to print your working directory?
  • What command can you use to clear the screen?
  • What command can you use to list the contents of your working directory?
  • Many commands require a path as an argument. Name and define the two types of paths.
  • Suppose your working directory is /users/jane. List two ways to change your working directory to /users.
  • What command can you use to create in your working directory a directory named android_app?
  • Suppose a file named Poker.java exists in your working directory. What command can you use to rename the file to PokerGame.java?
  • Suppose your working directory is /home/jane and in it exists a file named Contacts.java. Suppose the directory /home/jane/csci105/contacts exists. What command can you use to move Contacts.java to /home/jane/csci105/contacts?
  • Suppose your working directory is /home/jane and in it exists a file named Contacts.java. Suppose the directory /home/jane/csci105/contacts exists. What command can you use to copy Contacts.java to /home/jane/csci105/contacts?
  • Suppose Bookmarks.java exists in your working directory. What command can you use to delete Bookmarks.java?
  • Suppose your working directory is /home/jane and it contains a subdirectory named practice. What command can you use to delete the directory named practice (assume it is empty).
  • What is vi?
  • What are the 2 modes in vi, what are they used for, and how do you toggle between them.
  • What vi command writes the contents of the edited file to the hard drive?
  • What vi command terminates vi?
  • What vi command cuts/yanks 2 lines of code?
  • What vi command pastes the code that is in the clipboard to the location of the cursor?
  • What vi command replaces the character at the location of the cursor?
  • What vi command deletes a single character?
  • What vi command deletes 2 lines of code?
  • What vi command moves the cursor to the 20th line of code?
  • What vi command moves the cursor to the end of the current line.
  • What vi command moves the cursor to the beginning of the current line.