BJP5 Self Checks- Chapter One

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

What is the output produced from the following statements? System.out.println("\"Quotes\""); System.out.println("Slashes \\//"); System.out.println("How '\"confounding' \"\\\" it is!");

"Quotes" Slashes \// How '"confounding' "\" it is!

Which of the following can be used in a Java program as identifiers? Check all of the identifiers that are legal. ABC AnnualSalary B4 for sum_of_data "hello" _average println 42isThesolution first-name

ABC AnnualSalary B4 sum_of_data _average println

What is the output from the following Java program? (Assume that a tab is expanded into eight spaces.) public class Letter { public static void main(String[] args) { System.out.println("Dear \"DoubleSlash\" magazine,"); System.out.println(); System.out.println("\tYour publication confuses me. Is it"); System.out.println("a \\\\ slash or a //// slash?"); System.out.println("\nSincerely,"); System.out.println("Susan \"Suzy\" Smith"); } }

Dear "DoubleSlash" magazine, Your publication confuses me. Is it a \\ slash or a //// slash? Sincerely, Susan "Suzy" Smith

What is the difference between the file MyProgram.java and the file MyProgram.class? The .class file is for object-oriented programming and the .java file is for procedural programming. MyProgram.java is a source code file typed by the programmer, and MyProgram.class is a compiled executable class file that is run by the computer. The programmer writes the .class file first, and the .java file is generated automatically later. A .java file contains code written in the Java language, and a .class file contains code written in the C++ language. A .java file is a much larger binary file and a .class file is a smaller compressed version.

MyProgram.java is a source code file typed by the programmer, and MyProgram.class is a compiled executable class file that is run by the computer.

What is the output produced from the following statements? System.out.println("Shaq is 7'1"); System.out.println("The string \"\" is an empty message."); System.out.println("\\'\"\"");

Shaq is 7'1 The string "" is an empty message. \'""

What is the output produced from the following statements? (Treat tabs as aligning to every multiple of eight spaces.) System.out.println("\\\\"); System.out.println("'"); System.out.println("\ta\tb\tc"); System.out.println("\"\"\""); System.out.println("C:\nin\the downward spiral");

\\ ' a b c """ C: in he downward spiral

Which of the following method headers uses the correct syntax? public void static example() { public void static example{} ( public static void example() { public static example void[] { public static example() {

public static void example() {

What is the output of the following program? Note that the program contains several comments. public class Commentary { public static void main(String[] args) { System.out.println("some lines of code"); System.out.println("have // characters on them"); System.out.println("which means "); // that they are comments // System.out.println("written by the programmer."); ​ System.out.println("lines can also"); System.out.println("have /* and */ characters"); /* System.out.println("which represents"); System.out.println("a multi-line style"); */ System.out.println("of comment."); } }

some lines of code have // characters on them which means lines can also have /* and */ characters of comment.

Rewrite the following code as a series of equivalent System.out.println statements (i.e., without any System.out.print statements): System.out.print("Twas "); System.out.print("brillig and the "); System.out.println(" "); System.out.print(" slithy toves did"); System.out.print(" "); System.out.println("gyre and"); System.out.println( "gimble"); System.out.println(); System.out.println( "in the wabe." );

System.out.println("Twas brillig and the "); System.out.println(" slithy toves did gyre and"); System.out.println( "gimble"); System.out.println(); System.out.println( "in the wabe." );

Write a println statement that produces the following output: / \ // \\ /// \\\

System.out.println("/ \\ // \\\\ /// \\\\\\");

Which of the following is the correct syntax to output a message? Out.system.println"(Hello, world!)"; System.out.println("Hello, world!"); System.println(Hello, world!); System.println("Hello, world!"); System.println.out('Hello, world!');

System.out.println("Hello, world!");

What series of println statements would produce the following output? This is a test of your knowledge of "quotes" used in 'string literals.' You're bound to "get it right" if you read the section on ''quotes.''

System.out.println("This is a test of your"); System.out.println("knowledge of \"quotes\" used"); System.out.println("in 'string literals.'"); System.out.println(); System.out.println("You're bound to \"get it right\""); System.out.println("if you read the section on"); System.out.println("''quotes.''");

What series of println statements would produce the following output? "Several slashes are sometimes seen," said Sally. "I've said so." See? \ / \\ // \\\ ///

System.out.println("\"Several slashes are sometimes seen,\""); System.out.println("said Sally. \"I've said so.\" See? "); System.out.println("\\ / \\\\ // \\\\\\ /// ");

What is the output produced from the following statements? (Treat tabs as aligning to every multiple of eight spaces.) System.out.println("name\tage\theight"); System.out.println("Archie\t17\t5'9\""); System.out.println("Betty\t17\t5'6\""); System.out.println("Jughead\t16\t6'");

name age height Archie 17 5'9" Betty 17 5'6" Jughead 16 6'

The following program contains four errors. Correct the errors and submit a working version of the program. public class FamousSpeech public static void main(String[]) { System.out.println("Four score and seven years ago,"); System.out.println("our fathers brought forth on"); System.out.println("this continent a new nation"); System.out.println("conceived in liberty,"); System.out.println("and dedicated to the proposition"); System.out.println("that"); /* this part should System.out.println("all"); really say, System.out.println("men"); "all PEOPLE!" */ System.out.println("are"; System.out.println("created"); System.out.println("equal"); } }

public class FamousSpeech { public static void main(String[] args) { System.out.println("Four score and seven years ago,"); System.out.println("our fathers brought forth on"); System.out.println("this continent a new nation"); System.out.println("conceived in liberty,"); System.out.println("and dedicated to the proposition"); System.out.println("that"); System.out.println("all"); System.out.println("men"); System.out.println("are"); System.out.println("created"); System.out.println("equal"); } }

The following program contains three errors. Correct the errors and submit a working version of the program. public MyProgram { public static void main(String[] args) { System.out.println("This is a test of the") System.out.Println("emergency broadcast system."); } }

public class MyProgram { public static void main(String[] args) { System.out.println("This is a test of the"); System.out.println("emergency broadcast system."); } }

The following program contains four errors. Correct the errors and submit a working version of the program. public class SecretMessage { public static main(string[] args) { System.out.println("Speak friend"); System.out.println("and enter); }

public class SecretMessage { public static void main(String[] args) { System.out.println("Speak friend"); System.out.println("and enter"); } }


Kaugnay na mga set ng pag-aaral

Parts of Speech: Gerunds, Participles, and Infinitives

View Set

[Diabetes and Other Endocrine] Medical-Surgical Nursing Review Questions

View Set

Prakarya kelas 7 #makanan cepat saji

View Set

Med Surg I Prep U Chapter 10: Principles and Practices of Rehabilitation

View Set

Chapter 14: Later Life: The Physical Challenges of Old Age

View Set