Cmpt 125/126

Practice Exam Solutions

Dec 8th 2013

Practice Exam Solutions

1. List the eight Primitive Data types in Java

byte, short, int, long_______________________ float, double, boolean, char_________________ _____________________________________________ 2.

Name two indefinite loop statements in Java _while_______________________________________ _do__________________________________________

3.

Nesting Definite Loops Write a nested for loop to print the triangle of stars shown below to System.out. You will need to write one for loop for printing each line of the triangle, and another to print out the stars for each line. Required Output: * ** *** **** ***** ******

for(int i=0; i