0% found this document useful (0 votes)
44 views

Programming Exam

The document provides an overview of concepts and sample questions for a Level 1 Java exam, covering syntax, variables, operators, flow control, arrays, strings, methods, classes, and Git. It lists topics like variable declaration, basic operators, Boolean expressions, if/else statements, loops, arrays, strings, methods, and classes. It also provides 15 sample multiple choice and code writing questions testing these concepts.

Uploaded by

xiaopanga
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views

Programming Exam

The document provides an overview of concepts and sample questions for a Level 1 Java exam, covering syntax, variables, operators, flow control, arrays, strings, methods, classes, and Git. It lists topics like variable declaration, basic operators, Boolean expressions, if/else statements, loops, arrays, strings, methods, and classes. It also provides 15 sample multiple choice and code writing questions testing these concepts.

Uploaded by

xiaopanga
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Level1Exam: Level1ExamConcepts: Syntax Variabledeclaration BasicOperators + / * % BooleanExpressions ProgramFlowControl If else elseif nested Loops For While Nested Arrays

hile Nested Arrays Strings Methods Classes Git Level1ExamSampleQuestions: 1. Writeastatementthatwilldeclareavariablewiththevalueofpi(upto3rddigit) 2. Inthefollowingcodesample,circleallsyntaxerrors: intx=0 intyz,r charc=w if(x=>10) { System.println(xislarge): } y+=x 3. Whichofthefollowingarevalidjavaidentifiers?(chooseallvalidones)

a)Car b)$chultze c)per%cent d)_22skidoo 4. Forthefollowingproblems,writethecommandwhichwillsetztothevalueofthe requestedexpression. a. Example:addxandy

i. z=x+y b. Multiplyx,y,and3 c. Divideyby3timesx d. Theremainderofwand7 e. Subtractsfromq 5. Given: 1. intx=7,y=10,z=1 2. booleanfun=truesun=false Evaluatethefollowingexpressions: 1. x==7 2. 10!=y 3. x>y 4. y>=x+3 5. (x==y)||(fun) 6. !(sun&&fun)||(sun||fun) 7. (fun&&!(fun||sun)) 6. 7. Given 1. int[]a={1,2,3,4,5,6} 2. inti=a.length1 3. 4. while(i>=0){ 5. System.out.print(a[i]) 6. i 7. } What is the output?
8. Show the output from the snippet below

9. What is the size of a Char? (in bits)

10. Give a single Java Statement (using System.out.println() )that outputs the following line: Bob said, Its C:\window 11. How do we compare strings? please provide code example

12. Writeacompletemethodwhichacceptsanarrayofintegersanddisplaysahistogrambasedonthose
numbers.Forexample,iftheuserenters2541theprogramwilldisplay: ** ***** **** *

13. what is short circuiting? 14. How often should you commit? How often should you merge to the master branch? 15. Why should you have more than one branch? 16. Construct an array that contains the first three prime numbers with one line; 17. Write a method that will return true if the parameter is even and false if the parameter is odd, if given int parameter, myinteger. 18. Construct a method that will return a string stating what day of the week it is given a parameter of an integer between 1 and 7 where 1 is monday and 7 is sunday. 19. Write a function that will find the maximum and minimum of an array of arbitrary size. 20. Write a Book class with the following constructor, methods and fields a. field i. private string bookName ii. private int ISBN iii. private boolean isBorrowed; b. Constructor i. Book() 1. Default bookName =; 2. Default ISBN = 0; 3. Default isBorroed = false; ii. Book(string name, int ISBN) 1. bookName = name; 2. ISBN = ISBN; c. Methods i. public int getISBN(); ii. public String getBookName(); iii. public String toString() 1. output format = bookname + + ISBN iv. public boolean isBorrowed() v. public void borrow()

You might also like