Practise Problems for Labtest 5

Practise Problems for Labtest 5

Part 1, 2
Given a string that represents a valid URL, can you construct a URL object from it?
Are you able to use the services of the URL class in order to obtaining a URLConnection object from a URL object?
Can you construct or conceive of a scenario in which a URL object will not have a URLConnection object?
Are you able to recognize the scenarios in which the URLConnection object will indeed be a HttpURLConnection object? Do you understand why this cannot be known at compile time and instead can only be known at run time?

Given an HttpURLConnection object, can you query it in order to reveal information about the request and receive messages (the messages that were exchanged in order to establish the connection).
Are you able to access the InputStream that is associated with an HttpURLConnection object and construct a Scanner from it?
Are you able to use the services of Scanner in order to obtain all of the html-formatted text from a website?

Given all of the html-formatted text from a website, can you process that text in order to extract information (such as all the level 1 headings or the paragraph elements that belong to a certain class)

Part 3, 4
In constructing a URL object, are you able to invoke the constructor so as to implement a particular query string, in order to access dynamic html content?
Can you imagine a app that would prompt the user for input and then fetch the associated information from a website (e.g., the abstract stock exchange website which will given live stock quotes for two-character stock symbols)?
Given a website that provides dynamic services via a query string, can you build an app that will make use of the dynamic services?

Practise Problems for Labtest 4

Practice Questions for Labtest 04 (Set 1 of 2)
in addition to Ch 6 RQ's and Ch 6 exercises

Labtest 04 takes place Nov 17, 18, 21


Frequency
Given a string and a single target character, derive the frequency of the character within the string. You should be able to this using:
• Iteration and toCharArry()
• Iteration and charAt
• Iteration and substring
• replaceAll and length in combination

Given a string and a n-character long target string, derive the frequency of the
target string within the string. You should be able to this using:
• Iteration and substring
• replaceAll

Matching
Given a description of a domain of acceptable strings (and unacceptable strings), construct a test to see whether a given string is acceptable. You should be able to this using:
• if-elseif-else block and string equality testing
• matches and regular expressions


Implement a case-insensitive check whether two strings are the same


Substitution/Removal
Given a string, a single target character and a replacement character, implement character substitution. You should be able to this using:
• Iteration, condition testing, and string concatenation
• Iteration, condition testing, and a string buffer
• replaceAll
• all of the above, but with character removal rather than substitution

Given a string, a target string and a replacement string, implement substring substitution. You should be able to this using:
• Iteration, condition testing, and string concatenation
• Iteration, condition testing, and a string buffer
• Iteration, indexOf, and string concatenation
• Iteration, indexOf, and a StringBuffer
• replaceAll
• all of the above, but with substring removal rather than substitution

Given a description of a domain of acceptable strings (and unacceptable strings), implement code to remove all matching substrings
• replaceAll


Modification/Concatenation
Modification of a string in a position-sensitive manner, such as:
– user enters first and family name, separated by a space. want to insert the middle name into the string
– use String, use substring to split, then use concatenation and reassignment
– use StringBuffer, use insert

Given a string composed using string concatenation, accomplish the same result using a StringBuffer object



Practise Problems for Labtest 3

Labtest03 takes place Thurs, Nov 3, Fri Nov 4, Mon Nov 7.

Given two images, can you come up with a way to determine:
-whether they the same size (horizontally or vertically)?

-which pixels are the same and which pixels are different (matching according to position)
Given two images with the same dimensions, could you iterate over all of the pixels in one image and do a comparison to the corresponding pixel in the other image?
-could you do the same even if the two images were of two different sized?

if pixels are different, how might one or the other be modified to:
-match the other
-be the average of the two with respect to any or all of the RGB components
-be the sum of the two, wrt to any or all of the RGB values

Could you do the above conditionally?
e.g., for only some rows or some columns?

Could you implement "near matching" instead of "complete matching" for the pixels? think about how to characterize how "close" the colour of two pixels.

About the img package

Some folks are running into difficulties using the jar file containing the img package.
The source files are now posted at http://www.cse.yorku.ca/course/1710/files/
You can bring them into your eclipse project directly.

Regarding the Week#1 Lab (applies to all sections LAB01, LAB02, LAB03)

The first lab session of term is typically challenging to conduct since it requires that students first obtain their cse***** account, which can be time-consuming (e.g, eat up most of the lab session time).
So here is a compromise:

  • The instructions for the Week#1 Lab can be found here.
  • The lab must be completed in CSEB1002 and it must be completed prior to the lecture on Tuesday Sept 13th.
  • Ossama, one of the TAs will be in the lab during the regularly slotted times to provide assistance, if needed. But if you like, you may complete the lab on your own time.
  • The hours of operation for the lab CSE1002 can be found here: http://www.cse.yorku.ca/prism/hours.html (please note that on this page the Digital Media lab is being called the Maxwell lab)
  • If you have any questions about the lab, please ask Ossama during one of the labs.