Java & SQL Test
Java & SQL Test
Name :
1. The following options are not part of the underlying data type()
A. boolean C. double
B. char D. String
2. When manufacturing (new) an array, specify the length of the array in order to allocate
memory for the array.
A. TRUE B. FALSE
3. In Java, when a high-precision data type is assigned a value to a low-precision data type
through forced type conversion, its value remains unchanged.
A. TRUE B. FALSE
4. (x > 0 || x < 10 && y < 0) and ((x > 0 || x < 10) && y < 0) value is same
A. TRUE B. FALSE
5. The elements of an array in Java can be quantities of simple data types or objects of a certain
class.
A. TRUE B. FALSE
III. Java
(20 points)
1. Make a simple program that can Input three integers x, y, z and output these three numbers
sorted from small to large. Put the source code and the output with 2 different input below.
(10 points)
2. Write a nested loop program to calculate from integer 1 to 100, print output of every number
addition and the final result! Put the source code and the output below. (10 points)
IV. SQL
(50 points)
1. Write a statement to create Table which has 2 Primary Key column, the first one is DESC
ordered and the second PK is ASC ordered (7 points)
2. There are the following data tables in the database, please complete the following operations
student
Studentid Varchar 10 PK
Name Varchar 10
Sex Varchar 2
course
CourseID Varchar 10 PK
CourseName Varchar 40
Teacher Varchar 10
sc
Studentid Varchar 10 PK
CourseID Varchar 40
Grade Float
(1) Query the names, course numbers and grades of students whose scores are greater than
85, and follow the ascending order of course numbers (4 points)
(2) Update the score of the computer subject of the student named "Michael Jordan" to 90
points (3 points)
(3) Please write down the statement that creates the "Student" table Student (3 points)
(4) In the student table, query all the information of the students in ascending order of
student ID whose names do not start with "Diana", "Sam", and "David". (10 points)
(5) Delete the course data whose teacher is "Justin Br" in the course table (3 points)
(6) Add 3 more data in the sc table with one query (5 points)
(7) Query the information of students who do not study all courses, but at least take one
course (10 points)
Sample output:
2 David Brown M 4
4 Diana Rose F 1
5 David Harley M 2
(8) Find out the student numbers and names with only two courses (5 points)