4

Click here to load reader

Computer Science 1 Midterm Study Guidechs.hcpss.org/.../files/Computer-Science-1-Barrett-Midterm-Review.pdf · BARRETT&2016& Computer&Science&DST:&Midterm&Study&Guide& & Things&to&study:&Chapters&3,&4,&and&5&notes.&&

  • Upload
    vukiet

  • View
    212

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Computer Science 1 Midterm Study Guidechs.hcpss.org/.../files/Computer-Science-1-Barrett-Midterm-Review.pdf · BARRETT&2016& Computer&Science&DST:&Midterm&Study&Guide& & Things&to&study:&Chapters&3,&4,&and&5&notes.&&

BARRETT  2016  

Computer  Science  DST:  Midterm  Study  Guide    

Things  to  study:  Chapters  3,  4,  and  5  notes.              Chapter  4  Exercises              Chapter  5  PracticeProblems    

 *  Our  assigned  programs  are  available  via  the  class  webpage  (BBarrett2016.weebly.com).    

 Chapter  3  Topics:  Chapter  3  Vocab,  the  blue  items  on  the  PowerPoint  slides.    

• print  vs  println  • Escape  sequences    • Code  Conventions  • Syntax  errors  

 Chapter  4  Topics:  Chapter  4  Vocab,  the  blue  items  on  the  PowerPoint  slides.    

• Variables  - declaration,  naming  convention  - assignment  statements  - primitive  data  types    - Abstract  data  types  - Object  instantiation  

• Scanner  • Numeric  expressions  • Assignment  operators  • Constants  (naming  convention)  

 Chapter  5  Topics:  All  chapter  5  items  depend  on  how  far  we  get  in  class.    

• Relational  operators  • if  statements  • else  • nested  if  statements  • else  if  

   

       

Page 2: Computer Science 1 Midterm Study Guidechs.hcpss.org/.../files/Computer-Science-1-Barrett-Midterm-Review.pdf · BARRETT&2016& Computer&Science&DST:&Midterm&Study&Guide& & Things&to&study:&Chapters&3,&4,&and&5&notes.&&

BARRETT  2016  

     

Example  Questions:  Determine  the  appropriate  variable  type  for  each  of  the  following  values  (1  point  each):  Number  of  students  in  a  class.       The  average  of  test  scores.  Whether  or  not  a  student  passed  a  class.     The  price  of  a  football.  A  letter  grade.             Whether  or  not  a  pig  was  purchased.  The  age  of  a  pig.           How  many  pigs  are  in  a  barn.  An  answer  to  a  multiple  choice  question.     The  price  of  bacon.        

6.Which  of  these  statements  will  result  in  the  output:  Turkey  Taco  a.  System.out.println(Turkey  Taco);  b.  system.out.println(“Turkey  Taco”);  c.  System.out.println(“+Turkey  Taco”);  d.  System.out.println(“Turkey  Taco”)  

 7.  What  will  be  the  result  of  the  following  equation:     3  *  4  -­‐  15  %  6  =  _____  a.    -­‐3                                                          b.  9  c.    3                                              d.    10    8.  Which  of  these  is  NOT  a  primitive  data  type:  

a.  int  b.  char  c.  Scanner  d.  boolean    

9.  A  class  name  should  be  written:  a.  LikeThis  b.  likeThis  c.  likethis  d.  Like_This  

 10.  Scanner  is  an  example  of  a(n):  

a.  primitive  data  type  b.  Java  data  type  c.  native  data  type  d.  abstract  data  type    

11.  Write  a  statement  that  outputs  your  name  enclosed  in  quotations  (ie.  “Your  Name”).  

Page 3: Computer Science 1 Midterm Study Guidechs.hcpss.org/.../files/Computer-Science-1-Barrett-Midterm-Review.pdf · BARRETT&2016& Computer&Science&DST:&Midterm&Study&Guide& & Things&to&study:&Chapters&3,&4,&and&5&notes.&&

BARRETT  2016  

 12.  Write  a  statement  that  instantiates  an  object  named  ‘card’  of  the  class  Playing  Card.    

13.  Identify  the  four  syntax  errors  in  the  following  code.  (1  point  each)  Int  x  =  5;  double  y  =  8  System.Out.println(“The  product  is:”  x  *  y);    

14.  What  is  our  main  method?    

15.  Create  an  algorithm  for  a  GradeAvg  application  that  prompts  the  user  for  five  grades  and  then  displays  the  average  of  the  grades.    Assume  the  grades  are  integer  values  (for  example,  89,  87,  and  so  on).    Real  division  should  be  performed  when  calculating  the  average.  Final  output  should  be  in  percentage  format.    

 16.  What  will  be  the  output  of  the  following  code?  int  num  =  10;    if(num  <  0)     num  +=  5;      System.out.println(num);    

a.  10  b.  11  c.  16  d.  none  of  these    17.  What  will  be  the  output  of  the  following  code?  int  num  =  -­‐10;    if(num  >  0){     num  +=  5;    }else{     num  -­‐=  5;  }  System.out.println(num);    

a. -­‐10    b.  -­‐11    c.  -­‐15    d.  none  of  these                  

Page 4: Computer Science 1 Midterm Study Guidechs.hcpss.org/.../files/Computer-Science-1-Barrett-Midterm-Review.pdf · BARRETT&2016& Computer&Science&DST:&Midterm&Study&Guide& & Things&to&study:&Chapters&3,&4,&and&5&notes.&&

BARRETT  2016  

 18.  What  will  be  the  value  of  bonus  after  the  following  code  is  executed?  int  bonus;  int  sales  =  10000;    if(sales  <  5000){     bonus  =  200;    }else  if  (sales  <  7500){     bonus  =  500;  }else  if  (sales  <  10000){     bonus  =  750;  }else  if  (sales  <  20000){     bonus  =  1000;  }else{     bonus  =  1250;  }    

a. 200    b.  500    c.  750    d.  1000    e.  1250