Friday, November 16, 2012

Java Chapter 1 Review

Java Programming 6th edition
Chapter 1: Review Questions

1. The most basic circuitry-level computer language, which consists of on and off switches, is machine language. (b)

2. Languages that let you use a vocabulary of descriptive terms, such as read, write, or add, are known as high-level languages. (a)

3. The rules of a programming language constitue its syntax. (d)

4. A compiler translates high-level language statements into machine code. (c)

5. Named computer memory locations are called variables. (b)

6. The individual operations used in a computer program are often grouped into units called procedures. (a)

7. Envisioning program components as objects that are similar to concrete objects in the real world is the hallmark of object-oriented programming (c).

8. The value of an object's attributes are also known as its state. (b)

9. An instance of a class is a(n) object. (a)

10. Java is architecturally neutral. (c)

11. You must compile classes written in Java into bytecode. (a)

12. All Java programming statements must end with semicolon. (c)

13. Arguments to methods always appear within parenthesis. (a).

14. In a Java program, you must use dots to separate classes, objects, and methods. (c)

15. All Java applications must have a method named main(). (b)

16. Nonexecuting program statements that provide documentation are called comments. (c)

17. Java supports three types of comments: line, block and javadoc. (a)

18. After you write and save a Java application file, you compile and then interpret it. (d)

19. The command to execute a compiled Java application is java. (d)

20. You save the text files containing Java source code using the file extension .java. (a)

Exercises (coming soon)

1.
a. weeklySales - legal
b. last character - illegal
c. class - illegal
d. MathClass - legal
e. myfirstinitial - legal
f. phone# - illegal
g. abcdefghiklmnop - legal
h. 23jordan - illegal
i. my_code - legal
j. 90210 - illegal
k. year2013budget - legal
l. abffraternity - legal

2.
a. TelevisionSet: size, make, numOfInputs
b. EmployeePaycheck: name, amount, department
c. PatientMedicalRecord: name, age, weight

3.
a. Politician: chrisChristie, mittRomney, barackObama
b. SportingEvent: superbowl, worldSeries, pGATour
c. Book: fightClub, oneFlewOverTheCuckoosNest, harryPotter

4.
a. mickeyMouse: Mouse, DisneyCharacter, Animal
b. myDogSpike: Dog, Animal, Pet
c. bostonMassachusetts: City, StateCapital, BaseballTeamHomeCity


public class Name
/*Displays my name*/
{
 public static void main(String[] args)
 {
  System.out.println("Name Line 1");
 }
}
public class Address
/*Displays my name and address*/
{
 public static void main(String[] args)
 {
  System.out.println("Address Line 1");
  System.out.println("Address Line 2");
  System.out.println("Address Line 3");
 }
}
public class Tree
/*Displays a tree pattern on the screen*/
{
 public static void main(String[] args)
 {
  System.out.println("   X   ");
  System.out.println("  XXX  ");
  System.out.println(" XXXXX ");
  System.out.println("XXXXXXX");
  System.out.println("   X   ");
 }
}
public class Initial
/*Displays my initials */
{
 public static void main(String[] args)
 {
  System.out.println("    AA     M     M");
  System.out.println("   A  A    M M M M");
  System.out.println("  AAAAAA   M  M  M");
  System.out.println(" A      A  M     M");
  System.out.println("A        A M     M");
 }
}
public class Diamond
/*Displays a Diamond */
{
 public static void main(String[] args)
 {
  System.out.println("  *  ");
  System.out.println(" * * ");
  System.out.println("* * *");
  System.out.println(" * * ");
  System.out.println("  *  ");
 }
}
//Displays the following comment:Program comments are nonexecuting statements you add to a file for the purpose of documentation.
/*Displays the following comment: Program comments are nonexecuting statements you add to a file for the purpose of documentation. */
/**Displays the following comment: Program comments are nonexecuting statements you add to a file for the purpose of documentation. */

public class Comments
{
 public static void main(String[] args)
 {
  System.out.println("Program comments are nonexecuting statements you add to a file for the purpose of documentation.");
 }
}
//Displays the following comment: Program comments are nonexecuting statements you add to a file for the purpose of documentation.
/*Displays the following comment: Program comments are nonexecuting statements you add to a file for the purpose of documentation. */
/**Displays the following comment: Program comments are nonexecuting statements you add to a file for the purpose of documentation. */

import javax.swing.JOptionPane;

public class CommentsDialog
{
 public static void main(String[] args)
 {
  JOptionPane.showMessageDialog(null, "Program comments are nonexecuting statements you add to a file for the purpose of documentation.");
 }
}
import javax.swing.JOptionPane;

public class BurmaShave
/*Displays a Burma Shave rhyme in a dialog box*/
{
 public static void main(String[] args)
 {
  JOptionPane.showMessageDialog(null, "Shaving brushes");
  JOptionPane.showMessageDialog(null, "You'll soon see 'em");
  JOptionPane.showMessageDialog(null, "On a shelf");
  JOptionPane.showMessageDialog(null, "In some museum");
  JOptionPane.showMessageDialog(null, "Burma Shave");
 }
}
public class CardLayout
/*Displays an attractive layout of information in a typical business card*/
{
 public static void main(String[] args)
 {
  System.out.println("Name Line 1");
  System.out.println("Address Line 1");
  System.out.println("Address Line 2");
  System.out.println("Home: Home Phone 1");
  System.out.println("Work: Home Phone 2");
 }
}
import javax.swing.JOptionPane;

public class RandomGuess
/* Guessing game where a user is challenged to guess a random number*/
{
 public static void main(String[] args)
 {
  JOptionPane.showMessageDialog(null, "Think of a number between 1 and 10.");
  JOptionPane.showMessageDialog(null, "Is it: " + (1 + (int)(Math.random()*10)));
 }
}

17 comments:

  1. I have read your article, it is very informative and for me.I admire the valuable information you offer in your articles. Thanks for posting it..

    java tutorial

    ReplyDelete
  2. It seems you are so busy in last month. The detail you shared about your work and it is really impressive that's why i am waiting for your post because i get the new ideas over here and you really write so well.
    Data Science course in rajaji nagar
    Data Science with Python course in chenni
    Data Science course in electronic city
    Data Science course in USA
    Data science course in pune | Data Science Training institute in Pune

    ReplyDelete
  3. Very nice post here and thanks for it .I always like and such a super contents of these post.Excellent and very cool idea and great content of different kinds of the valuable information's.
    rpa training in bangalore
    best rpa training in bangalore
    rpa training in pune | rpa course in bangalore
    rpa training in chennai

    ReplyDelete
  4. Thanks for the good words! Really appreciated. Great post. I’ve been commenting a lot on a few blogs recently, but I hadn’t thought about my approach until you brought it up. 
    Best Devops Training in pune
    Devops Training in Bangalore
    Microsoft azure training in Bangalore
    Power bi training in Chennai

    ReplyDelete
  5. Hmm, it seems like your site ate my first comment (it was extremely long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your blog. I as well as an aspiring blog writer, but I’m still new to the whole thing. Do you have any recommendations for newbie blog writers? I’d appreciate it.
    AWS Course Interview Questions and Answers for Freshers | AWS Interviews Questions and Answers for Devops
    AWS Tutorial – Besant Technologies
    AWS Interview questions and answers for Sysops |AWS Interview Question and Answers BlogSpot
    AWS Tutorial For Beginners | AWS Tutorial with AWS Training Videos

    ReplyDelete
  6. Thanks for such a great article here. I was searching for something like this for quite a long time and at last I’ve found it on your blog. It was definitely interesting for me to read  about their market situation nowadays.
    AWS Training in Bangalore
    AWS training in sholinganallur
    AWS training in Tambaram
    AWS training in Velachery

    ReplyDelete
  7. Hi, thanks for your blog, if you want to learn about programming languages like java, php, android app, embedded system etc. I think this training institute is the best one.
    Best java training in coimbatore
    Android training in coimbatore
    Networking training in coimbatore

    ReplyDelete
  8. The world's leading casino | Woorica Casinos
    If you 블랙 잭 무기 live in the United 슬롯머신 무료 States, you should know that the vast majority 실시간 바카라사이트 of the 포커 페이스 뜻 land based casinos melbet in the US do not have land based casinos in the

    ReplyDelete
  9. Thank you for sharing! We appreciate your kind words. We're here to provide valuable information and insights, and we'll continue to do our best to keep you informed and engaged with excellent content. If you have more questions or need assistance with anything else, feel free to ask. Your feedback is invaluable.
    visit: Using SQL for Data Analysis: Querying and Manipulating Databases

    ReplyDelete
  10. I like your all post. You have done really good work. Thank you for the information.If you want to know about anything you can visit: UNDERSTANDING THE IMPORTANCE OF SUPPLY CHAIN OPTIMIZATION

    ReplyDelete
  11. great post, impressive , the way you explain java is hats off , no doubt getting high demands in IT is java , and your looking for it then visit java course in pune , thanks for this valuable post

    ReplyDelete
  12. This comment has been removed by the author.

    ReplyDelete
  13. This comment has been removed by the author.

    ReplyDelete