Shared Flashcard Set

Details

Java
Preparationn for IZ-804
13
Computer Science
Professional
09/08/2015

Additional Computer Science Flashcards

 


 

Cards

Term
What is JDBC API
Definition
The JDBC API is a Java API that can access any kind of tabular data, especially data stored in a Relational Database.
Term
Create a void function, that reads and print the values from a database.
Connection string ="jdbc:myDrive:myDatabase"
parameters: user and pass
db fields: int a, string b, float c
Definition
public static void readDB (String user, String pass) throws SQLException {
Connection con = DriverManager.getConnection ("jdbc:myDriver:myDatabase",user,pass);
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("SELECT A,B,C FROM TABLE1");

while (rs.next()){
System.out.println(":> "+rs.getInt("A")+rs.getString("B")+rs.getFloat("C"));
}
}
Term
Method to count characteres in a String
Definition
length()
Term
Method to access a character from a String.
Definition
charAt(int pos)
Term
Method to get a SubString from a String.
Definition
substring (int beginning, int end)
end = end -1
Term
How do you compare to String?
Definition
With the method equals()
Term
method to compare two Strings
Definition
int compareTo(String arg). Compares to String lexicographically.
Term
int v = "ZZZ".compareTo("zzz");
v = ?
Definition
v > 0
Term
int v = "ZZZ".compareTo("aaa");
v = ?
Definition
v > 0
Term
Method to convert to Uppercase.
Definition
String toUpperCase( String arg)
Term
What is the result of:
 
 "different".indexOf("f");
Definition
2
Term

What is the result of:

"different".split("e")[2];

Definition
nt
Term

import javax.swing.JFrame;

public class GUI_Problem1 {
    public GUI_Problem1() {
        for (int i = 0; i < 3; i++) {
            JFrame frame = new JFrame("Frame " + i);
            frame.setSize(300, 300);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        }
    }
}


What will be the result if an instance of GUI_Problem1 is created?


a- A run-time error will be produced.

b- Thress JFrames will be shown on the screen.

c- No JFrames will be shown on the screen.

d- Only one JFrame will be shown on the screen.

Definition
Answer: d

In the constructor of GUI_Problem1 three JFrame objects are created. However, these JFrame objects are not shown on the screen as "setVisible(true)" is not invoked on each of these objects. Therefore, no JFrames are observed on the screen.
Supporting users have an ad free experience!