mirror of
https://github.com/Brandon-Rozek/website.git
synced 2024-11-25 01:26:30 -05:00
124 lines
3.6 KiB
HTML
124 lines
3.6 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="author" content="Brandon Rozek">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<meta name="robots" content="noindex" />
|
|
<title>Brandon Rozek</title>
|
|
<link rel="stylesheet" href="themes/bitsandpieces/styles/main.css" type="text/css" />
|
|
<link rel="stylesheet" href="themes/bitsandpieces/styles/highlightjs-github.css" type="text/css" />
|
|
</head>
|
|
<body>
|
|
|
|
<aside class="main-nav">
|
|
<nav>
|
|
<ul>
|
|
<li class="menuitem ">
|
|
<a href="index.html%3Findex.html" data-shortcut="">
|
|
Home
|
|
</a>
|
|
</li>
|
|
<li class="menuitem ">
|
|
<a href="index.html%3Fcourses.html" data-shortcut="">
|
|
Courses
|
|
</a>
|
|
</li>
|
|
<li class="menuitem ">
|
|
<a href="index.html%3Flabaide.html" data-shortcut="">
|
|
Lab Aide
|
|
</a>
|
|
</li>
|
|
<li class="menuitem ">
|
|
<a href="index.html%3Fpresentations.html" data-shortcut="">
|
|
Presentations
|
|
</a>
|
|
</li>
|
|
<li class="menuitem ">
|
|
<a href="index.html%3Fresearch.html" data-shortcut="">
|
|
Research
|
|
</a>
|
|
</li>
|
|
<li class="menuitem ">
|
|
<a href="index.html%3Ftranscript.html" data-shortcut="">
|
|
Transcript
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
</nav>
|
|
</aside>
|
|
<main class="main-content">
|
|
<article class="article">
|
|
<h1>Exam Review Partial Answer Sheet</h1>
|
|
<p>Write a Java method to sum values of an array</p>
|
|
<pre><code class="language-java">// Assume variable numbers is an array of 10 integers
|
|
int sum = 0;
|
|
for (int i = 0; i < numbers.length; i++) {
|
|
sum += numbers[i];
|
|
}</code></pre>
|
|
<p>Write a Java method to test if an array contains a specific value</p>
|
|
<pre><code class="language-java">// Assume variable numbers is an array of 10 integers
|
|
int numWanted = 4;
|
|
boolean found = false;
|
|
for (int i = 0; i < numbers.length; i++) {
|
|
if (numbers[i] == numWanted) {
|
|
System.out.println("The number " + numWanted + " was found!");
|
|
found = true;
|
|
}
|
|
}
|
|
if (!found) {
|
|
System.out.println("The number " + numWanted + " was not found!");
|
|
}</code></pre>
|
|
<p>Write a Java method to find the index of an array element</p>
|
|
<pre><code class="language-java">// Assume variable numbers is an array of 10 integers
|
|
int numWanted = 4;
|
|
boolean found = false;
|
|
for (int i = 0; i < numbers.length; i++) {
|
|
if (numbers[i] == numWanted) {
|
|
System.out.println("The index of number " + numWanted + " is " + i);
|
|
}
|
|
}</code></pre>
|
|
<p>How many lines will the following loop print when it is run?</p>
|
|
<pre><code class="language-java">int i = 0;
|
|
while (i <= 6) {
|
|
System.out.println("i is now " + (i));
|
|
i++;
|
|
}</code></pre>
|
|
<pre><code>i is now 0
|
|
i is now 1
|
|
i is now 2
|
|
i is now 3
|
|
i is now 4
|
|
i is now 5
|
|
i is now 6</code></pre>
|
|
</article>
|
|
</main>
|
|
|
|
<script src="themes/bitsandpieces/scripts/highlight.js"></script>
|
|
<script src="themes/bitsandpieces/scripts/mousetrap.min.js"></script>
|
|
<script type="text/x-mathjax-config">
|
|
MathJax.Hub.Config({
|
|
tex2jax: {
|
|
inlineMath: [ ['$','$'], ["\\(","\\)"] ],
|
|
processEscapes: true
|
|
}
|
|
});
|
|
</script>
|
|
|
|
<script type="text/javascript"
|
|
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
|
|
</script>
|
|
<script>
|
|
hljs.initHighlightingOnLoad();
|
|
|
|
document.querySelectorAll('.menuitem a').forEach(function(el) {
|
|
if (el.getAttribute('data-shortcut').length > 0) {
|
|
Mousetrap.bind(el.getAttribute('data-shortcut'), function() {
|
|
location.assign(el.getAttribute('href'));
|
|
});
|
|
}
|
|
});
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|