CSE 174 Week 1 Flashcards
41 Questions
100 Views

CSE 174 Week 1 Flashcards

Created by
@NiftySard6198

Questions and Answers

What translates a source code program into executable object code?

Compiler

What is the extension used for Java byte code?

.class

What will be the output of the following calls to the print() method? System.out.println("hello"); System.out.println("world");

hello world

What will be the output of the following calls to the print() method? System.out.print("hello"); System.out.print("world");

<p>helloworld</p> Signup and view all the answers

Which of the following statements is true? (Select all that apply)

<p>The method hides its statements from its user, just as the accelerator pedal of a car hides from the driver the mechanisms of making the car go faster.</p> Signup and view all the answers

Which of the following is not one of the three general types of computer languages?

<p>Natural Language</p> Signup and view all the answers

The .class extension on a file means that the file:

<p>is produced by the compiler</p> Signup and view all the answers

The .java extension on a file means that the file:

<p>contains Java source code</p> Signup and view all the answers

Each Java statement should be terminated with _____________.

<p>semicolons (;)</p> Signup and view all the answers

The file produced by the Java compiler contains ________ that is executed by the _____________.

<p>byte code, Java Virtual Machine</p> Signup and view all the answers

What kind of error is created by the following code snippet? System.outt.println("Hello");

<p>Syntax error: the program will not compile</p> Signup and view all the answers

Which Java statement prints a blank line?

<p>System.out.println();</p> Signup and view all the answers

These two lines of code do not produce the same output. Why? System.out.println(7+3); System.out.println("7+3");

<p>The quotes cause the second expression to be treated as a string.</p> Signup and view all the answers

What step should you take to run the same Java program on a computer that has a different processor?

<p>Ensure the computer has a Java Virtual Machine installed.</p> Signup and view all the answers

What is the output from this code snippet? System.out.print("The sum is "); System.out.println("7+3");

<p>The sum is 7+3</p> Signup and view all the answers

A Java class with the name Printer has to be saved using the source file name:

<p>Printer.java</p> Signup and view all the answers

When a compiler finds a syntax error in a program, what happens?

<p>The compiler continues and may report about other errors but does not produce a Java class file.</p> Signup and view all the answers

What is the output from this code snippet? System.out.print("The sum is "); System.out.println(7+3);

<p>The sum is 10</p> Signup and view all the answers

Expected math result: 2.5 Java result: 2

<p>10/4</p> Signup and view all the answers

Expected math result: 0.3 Java result: 0.30000000000000004

<p>.1+.1+.1</p> Signup and view all the answers

Expected math result: 400000000 Java result:-294967296

<p>2000000000+2000000000</p> Signup and view all the answers

Which of the following is required in order to convert Java source code into Java byte code?

<p>A Java compiler</p> Signup and view all the answers

Which of the following is required in order to run Java byte code?

<p>A Java Virtual Machine</p> Signup and view all the answers

The name of a file containing Java source code must end with which extension?

<p>.java</p> Signup and view all the answers

The Java programming language is roughly how many years old?

<p>20</p> Signup and view all the answers

What is the most current major version of Java?

<p>9</p> Signup and view all the answers

The Java code you type in a text editor is typically referred to as...

<p>Java source code</p> Signup and view all the answers

Which of these best describes the structure of a Java program?

<p>A class that contains multiple methods</p> Signup and view all the answers

If a Java program contains multiple methods, how does the Java Virtual Machine know which method should be executed first?

<p>It will execute the method named main</p> Signup and view all the answers

In Java, a set of words contained within quotation marks is referred to as a...

<p>String</p> Signup and view all the answers

The missing quotation marks in the following line of code will result in what kind of error? System.out.println(Hi there!);

<p>compile-time error</p> Signup and view all the answers

In Java, an exception is an example of a:

<p>run-time error</p> Signup and view all the answers

If you compile and run a program, and the program prints "hello" but you wanted it to print "goodbye", then your program contains:

<p>a logic error</p> Signup and view all the answers

The part of a computer responsible for carrying out instructions is known as:

<p>the CPU</p> Signup and view all the answers

Which of the following are typically integrated into an IDE, including Dr.Java? (Select all that apply)

<p>Compiler</p> Signup and view all the answers

When using Dr.Java, which of the following techniques will fix the indentation in your source code?

<p>Select all the text and press Tab</p> Signup and view all the answers

What does Dr.Java's 'Interactions Pane' give as a result when you type: 47/10?

<p>4</p> Signup and view all the answers

What does Dr.Java's 'Interactions Pane' give as a result when you type: 1+.1?

<p>1.1</p> Signup and view all the answers

What does Dr.Java's 'Interactions Pane' give as a result when you type: "cat".length?

<p>3</p> Signup and view all the answers

What does Dr.Java's 'Interactions Pane' give as a result when you type: "13"+"14"?

<p>1314</p> Signup and view all the answers

Which of the following settings can you change in Dr.Java's preferences? (Select all that apply)

<p>Font color</p> Signup and view all the answers

Study Notes

Compiler and File Extensions

  • A compiler translates source code into executable object code.
  • The .class extension signifies Java byte code.
  • The .java extension indicates a file containing Java source code.

Output and Print Statements

  • System.out.println("hello"); followed by System.out.println("world"); outputs:
    hello
    world
    
  • System.out.print("hello") followed by System.out.print("world") outputs:
    helloworld
    

Methods and Language Types

  • A method encapsulates program statements to perform tasks and hides implementation details, similar to a car pedal.
  • Natural Language is not classified as a general type of computer language (compared to Machine and Assembly Language).

Java Class and Syntax

  • If a Java class is named Printer, the source file must be saved as Printer.java.
  • A syntax error, such as in System.outt.println("Hello");, prevents the program from compiling.

Java Output Basics

  • To print a blank line in Java, use System.out.println();.
  • System.out.print("The sum is "); System.out.println("7+3"); results in:
    The sum is 7+3
    
  • System.out.print("The sum is "); System.out.println(7+3); outputs:
    The sum is 10
    

Numerical Operations and Errors

  • Java rounds division, so 10/4 gives a result of 2 instead of the expected 2.5.
  • Floating-point arithmetic can yield unexpected results, as in the case of 0.1 + 0.1 + 0.1, giving 0.30000000000000004.
  • Adding two large integers, 2000000000 + 2000000000, can lead to an overflow, resulting in -294967296.

Java Compilation and Execution

  • A java compiler converts Java source code into byte code.
  • A java virtual machine is necessary to run the byte code.
  • The Java programming language is about 20 years old, with its current major version being 9.

Structural Elements of a Java Program

  • Java programming typically involves a class containing multiple methods.
  • The Java Virtual Machine identifies the method to execute first based on the main method.

Data Types and Errors

  • A sequence of characters in quotes is called a String.
  • Missing quotation marks in System.out.println(Hi there!); will cause a compile-time error.
  • Exceptions in Java represent run-time errors.
  • Logic errors occur when the program runs incorrectly, such as printing "hello" instead of "goodbye".

Computer Components and IDE Features

  • The CPU is responsible for executing instructions in a computer.
  • An Integrated Development Environment (IDE) may include features like editors, code formatters, debuggers, and compilers.
  • To fix indentation in Dr.Java, select all text and press Tab.

Interactive Results in Dr.Java

  • In Dr.Java's Interactions Pane:
    • Typing 47/10 yields 4.
    • 1 + .1 results in 1.1.
    • "cat".length returns 3.
    • "13" + "14" concatenates to 1314.

Dr.Java Preferences

  • Dr.Java's preferences allow customization, including right margin position, font size and color, and displaying line numbers.

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Description

Test your knowledge with these flashcards from CSE 174, focusing on key concepts related to compilers and Java programming. Each card presents a crucial term or concept to enhance your understanding of the material covered in Week 1. Ideal for revision and self-assessment.

More Quizzes Like This

Java Compiler and JVM Quiz
5 questions
Java Programming Basics Quiz
17 questions
Java 13: Compilers and Interpreters
28 questions
Use Quizgecko on...
Browser
Browser