






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







How does a computer's main memory differ from its auxiliary memory? - answer ✅✅All information in Main Memory will disappear when the computer shuts down, when all information that is stored in auxiliary memory will stay even after the computer shuts down. After you use a text editor to write a program, will it be in main memory or auxiliary memory? - answer ✅✅Auxiliary Memory When a computer executes a program, will it be in main memory or auxiliary memory? - answer ✅✅Main Memory How does machine language differ from Java? - answer ✅✅Machine code works in low-level code, where Java works with high-level code.
How does bytecode differ from machine language? - answer ✅✅bytecode consists of 1's and 0's, where machine language works with a set of actions. What would the following statements, when used in a Java program, display on the screen? int age; age = 20; System.out.println ("My age is"); System.out.println(age); - answer ✅✅My age is 20 Write a statement or statements that can be used in a Java program to display the following on the screen: 3 2 1 - answer ✅✅public class Count { public static void main(String[] args){ System.out.println(3); System.out.println(2);
Give a person's year of birth, the Birthday Wizard can compute the year in which the person's nth birthday will occur or has occurred. Write statements that can be used in a Java program to perform this computation for the Birthday Wizard. - answer ✅✅import java.util.Scanner; public class BirthdayWizard { public static void main(String[] args){ Scanner scan = new Scanner(System.in); System.out.println("Please supply year of birth:"); int year = scan.nextInt(); System.out.println("\nTo see at what year you would be what age, please supply your age:"); int age = scan.nextInt(); int sum = year + age; System.out.println("\nWhen you are " + age + " , the year will be: " + sum);
Write statements that can be used in a Java program to read two integers and display the number of integers that lie between them, including the integers themselves. For example, four integers are between 3 and 6: 3, 4, 5, and 6. - answer ✅✅import java.util.Scanner; public class UserCount { public static void main(String[] args){ int backVal1; int backVal2; Scanner scan = new Scanner(System.in); System.out.println("This program will take two separate values and add the missing values in between");
A single bit can represent two values: 0 and 1. Two bits can represent four values: 00, 01, 10, and 11. Three bits can represent eight values: 000, 001, 010, 011, 100, 101, 110, and
Self-Test Question 27 asked you to think of some attributes for a song object. What attributes would you want for an object that represents a play list containing many songs? - answer ✅✅• Total song amount
subtract 1 from k Write an algorithm that finds the maximum value in a list of values. - answer ✅✅maxValue = - 1 iterate through each list value { if list value is greater than maxValue then maxValue = list value } Write statements that can be used in a Java applet to draw the five interlocking rings that are the symbol of the Olympics. (Don't worry about the color.) - answer ✅✅import javax.swing.JApplet; import java.awt.Graphics; public class Olympics extends JApplet{ public void paint(Graphics g){ g.drawOval(50, 50, 100, 100); g.drawOval(110, 100, 100, 100); g.drawOval(170, 50, 100, 100); g.drawOval(230, 100, 100, 100);
g.drawOval(290,50, 100, 100); } } Find the documentation for the class Graphics in Java Class Library. (See Exercise 12.) Learn how to use the method drawRect. Then write statements that can be used in a Java applet to draw a square containing a circle. The circle's diameter and the square's side should be equal in size. - answer ✅✅import javax.swing.JApplet; import java.awt.Graphics; public class DrawSquare extends JApplet{ public void paint(Graphics g){ g.drawRect(0, 0, 200, 200); g.drawOval(0, 0, 200, 200); } }