Review Review Review - PowerPoint PPT Presentation

1 / 41
About This Presentation
Title:

Review Review Review

Description:

d. java and link. This is the only answer accepted if this question is asked in another exam ... { System.out.print(' Drop small cup into position'); (1) Missing ; ... – PowerPoint PPT presentation

Number of Views:70
Avg rating:3.0/5.0
Slides: 42
Provided by: hien2
Category:
Tags: cup | review

less

Transcript and Presenter's Notes

Title: Review Review Review


1
Review ReviewReview
2
Concepts
  • Comments definition, example, different types of
    comments
  • Class definition, example
  • Object definition, example
  • Data type
  • Byte, short, int, long, float, double
  • Char, boolean
  • String

3
Concepts
  • Assignment statement
  • Boolean expressions
  • Identifiers, constants
  • Commands
  • If
  • Switch
  • Do/While, While, and For

4
Concepts
  • File extension .java, .class
  • Compile
  • Textpad Compile Java and Run java
  • DOS javac and java

5
Project 1 (Section 01)
  • Average 93.14 (35 students submitted)

6
Project 1 (Section 2)
  • Average 97 (only 28 students submitted)

7
Lab section
8
Homework 1 (Section 01)
  • Avg 84.3. Max 99.

9
Homework 1 (Section 02)
  • Avg 88, Max 100

10
Rules for Midterm exam
  • Student ID is required
  • Dont
  • Leave the exam room after the exam is distributed
  • Use cell phone or computers (PC)
  • Talk with each other during the exam
  • Limit of questions you can ask teacher during
    exam time. If you ask more than two questions,
    you will have some points off taken from your
    exam.

11
Answers to Homework 1
  • 1. In general, commands to compile and execute a
    java program are
  • a. compile and run
  • b. compile and link
  • c. javac and java
  • d. java and link

This is the only answer accepted if this question
is asked in another exam
12
Homework 1 - Answer
  • 2. All Java program must have this method to run
  • a. hello()
  • b. start()
  • c. main()
  • d. method()

13
Homework 1
  • 3. Which of the following is not mandatory in
    variable declaration
  • a. a semicolon
  • b. an assignment
  • c. a variable name
  • d. a data type

14
Homework1
  • 4. You store java source code files with
    following extension?
  • a. .java
  • b. .class
  • c. .src
  • d. .javadoc

15
Homework1
  • 5. A single line comment in Java starts with
  • a.
  • b.
  • c. ,
  • d. //
  • e. none of the above

16
Homework1
  • 6. Java language is case sensitive
  • a. True
  • b. False

17
Homework1
  • 7. As long as a computer has a Java Virtual
    Machine, the same program written in the Java
    programming language can run on any computer
  • a. True
  • b. False

18
Homework1
  • 8. Which of the following is an invalid
    identifier?
  • a. one
  • b. Two
  • c. _3Four
  • d. 4Five

19
Homework1
  • 9. Which of the following is an invalid variable
    declaration?
  • a. String inputStr
  • b. int i0
  • c. boolean flag true
  • d. double, int, j0

20
Homework1
  • 10. Assuming the following declarations are
    executed in sequence, why are the second and the
    third declarations invalid?
  • int a,b
  • double a
  • double b
  • a. Both a and b are invalid identifiers.
  • b. Variable a has been declared
  • c. Variable b has been declared
  • d. Both variables a and b have been declared in
    the first declaration

21
Homework1
  • 11. The __new_____operator is used to create a
    new object

22
Homework 1
  • 12. Identifiers may not start with a ___number
    (digit)________ or contain__special/(non-alpha-num
    eric)_____characters, other than the underscore
    or the dollar sign

23
Homework 1
  • 13. char data type represents individual
    _character______

24
Homework 1
  • 14. Text data can be stored in _String__objects

25
Homework 1
  • 15. Constants __can not be (never be, are
    not)__changed during program execution

26
Homework 1
  • 16. Boolean expressions are built by use of
    _relational___operators and _boolean__________oper
    ators

27
Homework 1
  • 17. Every variable that we use in a Java program
    must be _declared/defined__________

28
Homework 1
  • 18. A Java program is composed of one or more
    ___classes__

29
Homework 1
  • 20. int a b
  • cant be used in variable declaration

30
Homework 1
  • 21.
  • double monthlyInterestRate
  • if (monthlyInterestRate gt 0.08)
    (monthlyInterestRate lt 0.5 )
  • System.out.println(Interest rate is invalid)
  • System.exit(1)
  • () is needed or remove )( before and after
  • should be take out
  • No value has been initialized for
    monthlyInterestRate

31
Homework 1
  • 22. char userChoicel
  • if (userChoice s)
  • System.out.print( Drop small cup into
    position) (1) Missing
  • else System.out.println( Drop large cup into
    position)
  • else System.exit(-1)

2. should be inserted here
Else should be taken out
32
Homework 1
  • 23. String choice5
  • switch(choice)
  • case 4 System.out.println( Right branch)
    break
  • default System.out.println( Default branch)
    break
  • 1. Switch doesnt support String data type. It
    must be char or int(bytes,short,int)

33
Homework 1
  • 24. int sum0
  • for (int i0, ilt 100)
  • sum i
  • 1 int i0, this comma should be semicolon
  • 2. Missing post body update (increment or
    decrement)
  • 3. semicolon after 100) should be taken out

34
Homework 1
  • 25. int x,y
  • x-10
  • y-20
  • if ( ygt0 xlt y)
  • System.out.println(" The output is "(xy))
  • else
  • System.out.println(" The output is "(x-y))
  • The output is 10
  • (Because -10-(-20) -1020 10)

35
Homework 1
  • 26. int count0, sum0
  • while (count lt 10)
  • sum count
  • count3
  • System.out.println(" Sum " sum)
  • count0 sum 0
  • count 3 sum 033
  • count 6 sum 369
  • count 9 sum 9918

36
Homework 1
  • 27. int nextToPrint 1
  • int maximum 10
  • while(nextToPrint lt maximum)
  • if (nextToPrint 2 ! 0)
  • System.out.print(nextToPrint" ")
  • nextToPrint nextToPrint 1
  • System.out.println()
  • 1 3 5 7 9

37
Homework 1
  • 28. int sum0
  • int i0
  • while (ilt5)
  • int j4
  • while (i!j)
  • sum j
  • jj-1
  • i
  • System.out.println(" Sum "sum)

Sum 30
38
Homework 1
  • sum0 i0
  • j4
  • sum 04 4
  • j3
  • sum 43 7
  • j2
  • sum 72 9
  • j1
  • sum 9110

39
Homework 1
  • i1
  • j4
  • sum 104 14
  • j3
  • sum 143 17
  • j2
  • sum 172 19

40
Homework 1
  • i2
  • j4
  • sum 194 23
  • j3
  • sum 233 26

41
Homework 1
  • i3
  • j4
  • sum 264 30
Write a Comment
User Comments (0)
About PowerShow.com