Thursday, November 13, 2014

Demo phần làm Game 2D (thuần java) trên Android

 

gacon_

https://play.google.com/store/apps/details?id=vn.cusc.game2d

Code nhỏ gởi email với java

Sử dụng thư viện mail của Java và tài khoản gmail để gởi thư điên.

1 package javamaildemo;
2 import java.util.Properties;
3 import java.util.logging.Level;
4 import java.util.logging.Logger;
5 import javax.mail.Authenticator;
6 import javax.mail.Folder;
7 import javax.mail.Message;
8 import javax.mail.PasswordAuthentication;
9 import javax.mail.Session;
10 import javax.mail.Store;
11 import javax.mail.Transport;
12 import javax.mail.internet.InternetAddress;
13 import javax.mail.internet.MimeMessage;
14
15 public class JavaMailDemo {
16 public static void main(String[] args) {
17 try {
18 // Authenticated and send mail
19 Properties props = System.getProperties();
20 props.put("mail.smtp.host", "smtp.gmail.com");
21 props.put("mail.smtp.port", "587");
22 props.put("mail.transport.protocol", "smtp");
23 props.put("mail.smtp.starttls.enable", "true");
24 props.put("mail.smtp.auth", "true");
25 props.put("mail.debug", "true");
26
27 Authenticator auth;
28 auth = new Authenticator() {
29 public PasswordAuthentication getPasswordAuthentication() {
30 return new PasswordAuthentication("ngotuongdan04@gmail.com", "ngotuongdan");
31 }
32 };
33
34 Session session = Session.getInstance(props, auth);
35 Message msg = new MimeMessage(session);
36
37 msg.setFrom(new InternetAddress("ngotuongdan04@gmail.com"));
38 msg.setSubject("Java mail demo");
39 msg.setRecipient(Message.RecipientType.TO, new InternetAddress("ntdan@ctu.edu.vn"));
40 msg.setContent("<h1>Hello ! How are you ?</h1>", "text/html");
41
42 Transport.send(msg);
43
44 /* check mail
45
46 props.put("mail.pop3.host", "pop.gmail.com");
47 props.put("mail.pop3.starttls.enable", "true");
48 props.put("mail.debug", "true");
49 props.put("mail.transport.protocol", "pop3");
50 props.put("mail.pop3.port", "995");
51
52 Session session = Session.getInstance(props);
53
54 Store stored = session.getStore("pop3");
55 stored.connect("pop.gmail.com",995,"ngotuongdan04@gmail.com", "ngotuongdan");
56 Folder folder = stored.getDefaultFolder();
57 folder.open(Folder.READ_ONLY);
58 System.out.print(folder.getMessageCount());
59 */
60 } catch (Exception ex) {
61 System.out.print(ex.toString());
62 }
63 }
64 }
65

Cần phải tham chiếu thêm thư viện mail.jar vào ứng dụng.

Wednesday, November 12, 2014

Winform C# 1 – Questions

Câu 1 _____is any action directed at the application.

[A] Event

[B] Method

[C] Class

[D] Object

Câu 2____property is used to get or set the object that contains data about the control.

[A] Value

[B] Tag

[C] Text

[D] Name

Câu 3 Which of the following statement with respect to Data Grid control are True? (Choose all correct answers)

[A] By default, the DataGrid display 1 page at a time.

[B] When the DataGrid control is set to a valid data source, the control is populated automatically

[C] Each field in the DataGrid is bound to a single column based on the DataSource

[D] The DataGrid control display data in tabular format and optionally supports data editing.

Câu 4 When an MDI parent form is closed, the Closing event of all MDI child forms are raised before the MDI parent form’s Closing event is raised

[A] False

[B] True

Câu 5 What of the followings is correct for creating a command object with the connection con?

[A] SqlCommand Cmd = con.SetSqlCommand(“Select * From Student”);

[B] SqlCommand Cmd = con.GetSqlCommand(“Select * From Student”);

[C] SqlCommand Cmd = new SqlCommand(con,”Select * From Student”);

[D] SqlCommand Cmd = new SqlCommand(“Select * From Student”, con);

Câu 6 The method can be used to draw a rectangle or a square depending on the coordinates passed as its argument.

[A] FillSquare

[B] FillRectangle

[C] DrawSquare

[D] DrawRetangle

Câu 7 General Project Properties are applicable to all project configurations and are set in the properties window.

[A] False

[B] True

Câu 8 Name the object which notifes other objects about an event

[A] Consumer

[B] Publisher

[C] Subscriber

[D] Tester

Câu 9 _____it the normal ouput type for a WinForm project

[A] Windows Application

[B] Console Application

[C] Class Library

[D] Windows Forms

Câu 10 We can generate Typed Dataset from a Datadapter

[A] False

[B] True

Câu 11 To preserve screen space on the monitor, VS.NET provides us with (Choose all answers) Note

[A] Class View Window

[B] Command Window

[C] Solution Explorer Window

[D] Auto-Hide Window

[E] Properties Window

[F] Tabbed Windows

Câu 12Images can be drawn using the _____method to of the Graphics class.

[A] PaintImage()

[B] DrawImage()

[C] CreateImage()

[D] FromImage()

Câu 13 DataSet store its data in XML

[A] False

[B] True

Câu 14 The ____control groups a set of controls within a non-labeled an scrollable frame

[A] PictureBox

[B] Tab

[C] Frame

[D] Panel

Câu 15 The ____feature of Windows Installer provider a standard method for distributing components and ensures that the installed component is of the correct version.

[A] VersionUpdate

[B] CAB

[C] Msi

[D] Merge Modules

Câu 16 To create an instance of the Font class using existing Font and FontStyle, the constructor is:

[A] public void Font(string fontname, float size);

[B] public Font(FontStyle fs, Font f);

[C] public void Font(Font f, FontStyle fs);

[D] public Font(Font f, FontStyle fs);

[E] public Font(string fontname, float size);

Câu 17 Which control is used to display a short, customized help message for individual controls on a form?

[A] ToolTip

[B] HelpText

[C] HelpTool

[D] ToolClass

Câu 18 For using SQL.NET Data Provider what using statement of the following is correct?

[A] using System.Data;

[B] using System.Data.SqlServer;

[C] using System.Data.OleDb;

[D] using System.Data.SqlClient;

Câu 19 OLE is the abbreviation for ____

[A] Object Like Environment

[B] Object Linking and Embedding

[C] Object Linking Environment

[D] Object Linking and Empower

Câu 20 Microsoft Windows Installer is shipped along with Windows 2000, Windows ME and Windows XP as an installation and configuration service.

[A] False

[B] True

Câu 21 Which namespace is VS.NET contains classes that help in constructing and sending emails?

[A] System.Web.Mail

[B] System.Mail

[C] System.Web.MailMessage

[D] System.Web.MailMessages

Câu 22 Statement 1: Tree View displays items like folders, drives etc.

Statement 2: List View display items like current folder contents.

[A] Only statement 2 is true

[B] Both the statements are true

[C] Only statement 1 is true

[D] Both the statements are false

Câu 23 The DataAdapter method is used to fetch the values from the data source to the DataSet and also to update the data source with the DataSet data.

[A] False

[B] True

Câu 24 To perform a change to a table using the Command object named Cmd, what statement of the following correct?

[A] Cmd.ExecuteReader()

[B] Cmd.ExecuteScalar()

[C] Cmd.ExecuteQuery()

[D] Cmd.ExecuteNonQuery()

[E] Cmd.ExecuteUpdate()

Câu 25 When a Data Form is created using the Data Form Wizard, which of the following classes are used by default?(Choose all correct answers)

[A] OleDbDataWriter

[B] OleDbDataAdapter

[C] OleDbStatement

[D] OleDbDataReader

[E] OleDbConnection

[F] OleDbCommand

Câu 26 ____property of a connection object is used to get or set the string used to open a database

[A] ConnectionParams

[B] ConnectionInfo

[C] StringConnection

[D] ConnectionString

Câu 27 property is used to get or set the data source that the grid is displaying data for.

[A] DataSrc

[B] DataSource

[C] DataSet

[D] DataMember

[E] DataSender

Câu 28 _____property is used to get or set the edges of the control are anchored to the edges of its container.

[A] Hang

[B] Fixed

[C] Anchor

[D] Dock

Câu 29 MessageBox is a type of dialog box

[A] False

[B] True

Câu 30 OLE is the abbreviation for Object Linking and Embedding

[A] False

[B] True

Câu 31 ____property is used to get or set the shortcut menu associated with the control.

[A] PopUpMenu

[B] SubMenu

[C] ContextMenu

[D] MainMenu

Câu 32 The DataReader component is used to get the read-only and forward-only data from the data source.

[A] False

[B] True

Câu 33 System.Windows.Forms is an important____of the class libraries in .NET framework?

[A] Namespace

[B] Class

Câu 34 To get values of the columns of the i-th row in a DataTable object named datatable, what of the follwings is correct?

[A] DataColumn array = datatable.Rows[i].ItemArray;

[B] String[]array = datatable.Rows[i].ItemArray;

[C] Object[]array = datatable.Rows[i].ItemArray;

[D] DataRow array = datatable.Rows[i].ItemArray;

Câu 35 What mode is VS.NET allow you to step through each line of code and trace the execution of your application?

[A] Neither Debug Mode nor Release Mode

[B] Both Debug Mode and Release Mode

[C] Release Mode

[D] Debug Mode

Câu 36 Link Lable is commands control?

[A] False

[B] True

[C] There is no link label control

Câu 37 Brushes can be created using one of the following classe(Choose all correct answers)

[A] ThinBrush

[B] ThickBrush

[C] PlainBrush

[D] TextureBrush

[E] SolidBrush

[F] LinearGradientBrush

[G] GradientBrush

Câu 38 What mode is VS.NET allow you create a portable exe(EXE) file?

[A] Neither Debug Mode nor Release Mode

[B] Debug Mode

[C] Both Debug Mode and Release Mode

[D] Release Mode

Câu 39 What statement in the followings is correct

I. The instance properties and methods are those, which are common to all the instances of the class.

II. The shared properties and methods are those, which are specific to a particular instance.

[A] Both of I and II statements are correct

[B] Both of I and II statements are incorrect

[C] Only II statement is correct

[D] Only I statement is correct

Câu 40 ADO.NET provides features for accessing traditional databases like SQL Server as well as databases, which are accessed using ____.(choose all correct answers)

[A] ODBC

[B] VB.NET

[C] OLEDB

[D] XML

[E] DataSets

Câu 41 Name the .NET data providers which are available is VS.NET?(Choose all correct answers)

[A] ODBC.NET Framework Data Provider

[B] SQL.NET Framework Data Provider

[C] OLEDB.NET Framework Data Provider

[D] Oracle.NET Framework Data Provider

[E] Access.NET Framework Data Provider

Câu 42 You can create your own table in DataSet

[A] False

[B] True

Câu 43 The____ event of the PrintDocument class is triggered immediately before each PrintPage event ocurs.

[A] StartPrint

[B] BeginPrint

[C] PrintPage

[D] QueryPageSettings

Câu 44 ___is the easiest way to allow the user to interact with the application.

[A] Label control

[B] Text control

[C] Button control

[D] Form

Câu 45 The term packaging imlies bundling up all the files in the application into a single file called a Distribution Unit

[A] False

[B] True

Câu 46 Which namespace does the class ListView belong to?

[A] System.Windows.Lists

[B] System.Windows.Drawing

[C] System.Windows.Paint

[D] System.Windows.Forms

Câu 47 The____property of a DataGrid control, allow filling various kinds of data in a DataGrid including data from a DataSet, DataViewManager, Arrays, Lists etc.

[A] DataRecords

[B] FillSchema

[C] Fill

[D] FillData

[E] DataSource

Câu 48 The Pen class belongs to the ____namespace and cannot be inherited

[A] System.Painting

[B] System.GraphicsObjects

[C] System.Graphics

[D] System.Drawing

Câu 49 ____are the visual effects supported in WinForms (Choose all correct answers).

[A] Collections

[B] Class Libraries

[C] Opaque Forms

[D] Visual Inheritance

[E] Control Anchoring

[F] Cotrol Docking

[G] Transparent Forms

Câu 50 Help is one of the most important but then also mostly forgotten part of any application

[A] False

[B] True

Câu 51 Which class represents shortcut menus that can be displayed when the user clicks the right mouse button over a control or area of the form?

[A] ToolMenu

[B] MainMenu

[C] ContextMenu

[D] FileMenu

Câu 52 The value of the HelpButton property is ignored if the maximize of minimize boxes are shown.

[A] False

[B] True

Câu 53 List the key elements of COM (choose all correct answers)

[A] A set of theorems which must be proven for checking the correctness of the object model

[B] A set of graphical symbol for modeling the objects

[C] A set of services for creating and exposing the classes

[D] A set of specifications defining the programming protocol

Câu 54 ____ are the Print support controls provided by WinForms.(Choose all correct answers)

[A] PrintPreview

[B] PrintFile

[C] PrintPreviewControl

[D] PrintDirectory

[E] PrintDocument

Câu 55 What of the followings are data validation mode in WinForms?(Choose all correct answers)

[A] Form-Level Validation

[B] There is no Data validation mode in Winforms

[C] Control-Level Validation

[D] Field-Level Validation

Câu 56 What of the folllowings is correct if we want to set the Achild form as a child form of the parent form named TheParent?

[A] AChild.MdiParent = TheParent;

[B] AChild.TheParent = true;

[C] Achild.MdiChild = AChild;

[D] TheParent.MdiChild = AChild;

[E] TheParent.AChild = true;

Câu 57 Class Library is one of the main components of the .NET framework and is divided in to ____

[A] Namespaces

[B] DLL components

[C] GUI components

Câu 58 To bind data to controls as ListBox, ComboBox, DataGrid, what type of data bindings shoud you use?

[A] Hybrid Data Binding

[B] Complex Data Binding

[C] Simple Data Binding

[D] Structured Data Binding

Câu 59 The ____control groups a set of controls within a non-labeled and scrollable frame

[A] PictureBox

[B] CheckedBox

[C] Panel

[D] Frame

Câu 60 ____property is used to get or set a value that is returned to the parent form when the button is clicked.

[A] ButonResult

[B] DialogResult

[C] ButtonValue

[D] ResultValue

[E] ResultDialog

Câu 61 Arrange the sequence in which the key events are triggered

[A] KeyPress, KeyUp, KeyDown

[B] KeyUp, KeyPress, KeyDown

[C] KeyDown, keyPress, KeyUp

[D] KeyPress, keyDown, KeyUp

[E] KeyUp, KeyDown, KeyPress

[F] KeyDown, KeyUp, KeyPress

Câu 62 The types of list box supported in Winforms are(Choose all correct answers)

[A] ListBox

[B] CheckedListBox

[C] ComboBox

[D] DropDownbox

Câu 63 What are thee steps involved involved in calling one from another form?(choose all answers)

[A] Create an instance of the calling form

[B] Create an instance of the form to be called

[C] Invoke Show

Câu 64 Which Control is used to display the current status of the application using framed windows?

[A] TreeView

[B] StatusBar

[C] ToolBar

[D] ListView

Câu 65 Which of the following objects can we use to read data from a Micorosoft SQL Server 2000 database? (choose all correct answers)

[A] SQLDataAdapter

[B] DataSet

[C] OleDbDataAdapter

[D] ADORecordSet

[E] XmlTextReader

Câu 66 Use DataReader when we want to have data scrollable

[A] False

[B] True

Câu 67 What is component is used to fetch the values from the data source to DataSet and also update the data source with data in the DataSet?

[A] DataWriter

[B] DataReader

[C] DataAdapter

[D] DataCommand

Câu 68 The ____property of the Form control is used to determine whether there are any MDI child forms open in your MDI application.

[A] ActiveMdiChildren

[B] ActiveMdiChild

[C] IsMdiChild

[D] IsMdiChildren

Câu 69 ____are the collection of reusable classes or types

[A] Namespaces

[B] Collections

[C] Class libraries

Câu 70 ____control combines the features of the TextBox and the ListBox controls

[A] ToolBar

[B] StatusBar

[C] Label

[D] ComboBox

Câu 71 A custom control should you use to verify an authorized aplication user called as _____

[A] Composite Custom Control

[B] Standard Control

[C] Single Control

[D] Complex Control

Câu 72 Each Merge Module holds distinctive version details that are used by Windows Installer

[A] False

[B] True

Câu 73 Which of the following statements with respect to ADO.Net are True? (Choose all correct answers)

[A] System built on ADO.NET are intrinsically highly scaleable

[B] ADO.NET objects are all strongly typed.

[C] When we use the DataSet object, ADO.NET is based on disconnected data access.

[D] in ADO.NET, the RecordSet is bound to the data source

Câu 74 The method ____of the Control class conceals the control from the user.

[A] Close

[B] visible

[C] Dispose

[D] Hide

Câu 75 What control support us to display the list items in different types as text only, text with small icons, text with large icons and report views?

[A] ListView

[B] ListBox

[C] CheckedListBox

[D] ComboBox

Câu 76 IntelliSence pops up a list of _____that can be called on an object (Choose all correct answers). Xem lai

[A] Hints

[B] Values

[C] Properties

[D] Links

[E] Tags

Câu 77 The____ control is used to display text when the mouse points to a particular control

[A] Toolbar

[B] StatusBar

[C] Menu

[D] ToolTip

Câu 78 What are the types of Dialog boxes?(choose all correct answers)

[A] Custom dialog boxes

[B] Common dialog boxes

[C] Modeless dialog boxes

[D] Modal dialog boxes

Câu 79 which class is the base class for all the controls that can be used in Windows Forms?

[A] Control

[B] Controls

[C] Forms

[D] Objects

Câu 80 GDI + resides in _____ assembly.

[A] System.Painting

[B] System

[C] System.Graphics

[D] System.Drawing

Câu 81 The ____ property of the LinkLabel control is used to specity the text, which has to be displayed as a link.

[A] HyperLink

[B] URLName

[C] LinkName

[D] LinkArea

Câu 82 What of the following are correct for creating a connection object to database named MyDB? (Choose all correct answers)

[A] SqlConnection con = new SqlConnection(“server=myserver;

Integrated Security = SSPI; database=MyDB”);

[B] SqlConnection con = new SqlConnection(“server=myserver”

Intergrated Security=SSPI; Data Source=MyDB);

[C] SqlConnection con = new SqlConnection(“Data Source=myserver;

Integrated Sercurity=SSPI; Initial Catalog=MyDB”);

C©u 83 List the advantages of DCOM (Choose all correct answers)

[A] Provides Location Transparency(Distributed Architecture)

[B] Platform independent

[C] Fully Language Independent

[D] Supports version compatibility

C©u 84 The view types supported in Winforms are (choose all correct answers)

[A] Text with large icons

[B] Text only

[C] Text with small icons

[D] Report view

C©u 85 If maximize and minimize buttons are displayed then the HelpButton property is ignored.

[A] False

[B] True

C©u 86 The ____ event of the Form control is used to perform tasks such as allocating resources used by the form

[A] Allocate

[B] Activate

[C] Load

[D] Activated

C©u 87 To get values of the colums of the i-th row in a DataTable object named datatable, what of the followings is correct?

[A] Object [] array = datatable.Rows[i].ItemArray;

[B] DataColumn array = datatable. Rows[i].ItemArray;

[C] String[] array = datatable. Rows[i].ItemArray;

[D] DataRow array = datatable. Rows[i].ItemArray;

Monday, November 10, 2014

JComboBox – Display and Value from Item

Do quá trình làm đồ án Java có nhiều bạn gặp khó khăn trong việc load dữ liệu vào JComboBox. Trong bài này tôi hướng dẫn một đoạn code nhỏ để các bạn tham khảo.

image

Bước 1: Định nghĩa nội dung cho một phần tử trong ds của JComboBox

1 class Item {
2 public Item(int id, String name, int price) {
3 this.id = id;
4 this.name = name;
5 this.price = price;
6 }
7
8 private int id;
9 private String name;
10 private int price;
11
12 public int getId() {
13 return id;
14 }
15
16 public void setId(int id) {
17 this.id = id;
18 }
19
20 public String getName() {
21 return name;
22 }
23
24 public void setName(String name) {
25 this.name = name;
26 }
27
28 @Override
29 public String toString() {
30 return getName() + "\t" + getPrice();
31 }
32
33 public int getPrice() {
34 return price;
35 }
36
37 public void setPrice(int price) {
38 this.price = price;
39 }
40 }
Bước 2: Gán dữ liệu vào danh sách và đưa lên JComboBox


1 private void load()
2 {
3 DefaultComboBoxModel model = new DefaultComboBoxModel();
4 model.addElement(new Item(1,"Mit",8000));
5 model.addElement(new Item(2,"Cam", 15000));
6 model.addElement(new Item(2,"Xoai", 20000));
7 jComboBox1.setModel(model);
8 }

Bước 3: Nhận giá trị (khóa, ID) của từ JComboBox khi chọn một phần từ từ giao diện


- Đăng ký sự kiện chọn phần tử từ ds





1 private void jComboBox1ItemStateChanged(java.awt.event.ItemEvent evt) {
2 this.setTitle( ((Item)jComboBox1.getSelectedItem()).getId()+"");
3 }


Tới đây chạy lại from để quan sát kết quả.


 


Mã nguồn tham khảo ở đây


http://1drv.ms/10JvXRm


Video tham khảo


http://youtu.be/wvJ155iuni0?list=UUQ8F8U5jZwjS4MZ5JYX5W2A

Friday, November 7, 2014

Một số câu hỏi ôn tập môn học DBSJ

 

Một số câu hỏi ôn lý thuyết

1. JDBC and ODBC are identical?
A. True
B. False
2. How many kinds of JDBC drivers?
A. 10
B. 3
C. 4
D. many
3. The JDBC API is a Java API for accessing virtually any kind of tabular data
A. False
B. True
4. What is the correct statement about CallableStatement interface? (choose 1)
A. It defines a statement to create a stored-procedure
B. It contains a call to a stored-procedure
C. It defines a store-procedure
5. Which is the default port number of RMI Registry Server?
A. 1023
B. 1099
C. 1069
6. Which of the following statements is correct for retrieving all fields from Student table?
A. String sql=”SELECT FROM Student”;
Statement st=cn.createStatement(sql);
ResultSet rs=st.executeQuery();
B. String sql=”SELECT FROM Student”;
Statement st=cn.createStatement();
ResultSet rs=st.executeQuery(sql);
7. If you need to use a stored procedure with output parameters, which of the following statement type should be used to call the procedure?
A. PreparedStatement
B. CallableStatement
C. Statement
8. From which object do you ask for DatabaseMetaData?
A. DriverManager
B. ResultSet
C. Connection
D. Driver
9. Which character is used to represent an input parameter in a CallableStatement?
A.
B. #
C. ?
D. %
10. Which one of the following will not get the data from the first column of ResultSet rs, returned from executing SQL statement: SELECT name, rank, serialNo FROM employee.
A. rs.getString(“name”);
B. rs.getString(1);
C. rs.getString(0);
11. Which class contains the transaction control method setAutoCommit, commit, and rollback?
A. Statement
B. Connection
C. ResultSet
12. You can use an applet in RMI program as ________
A. None of the other options
B. Server program
C. Client program
13. Which of the following will not cause a JDBC driver to be loaded and registered with the DriverManager?
A. Class.forName(driverString);
B. new DriverClass();
C. Include driver name in jdbc.drivers system property
D. None of the above
14. SQLWarnings from multiple Statement method calls (like executeUpdate) will build up until you ask for them all with getWarnings and getNextWarning.
A. True
B. False
15. If one intends to work with a ResultSet, which of these PreparedStatement methods will not work?
A. execute()
B. executeQuery()
C. executeUpdate()
16. Can a ResultSet be reliably returned from a method that creates a Statement and executes a query?
A. Yes
B. No
17. How can I use JDBC to create a database?
A. Include create=true at end of JDBC URL
B. Execute "CREATE DATABASE jGuru" SQL statement
C. Execute "STRSQL" and "CREATE COLLECTION jGuru" SQL statements
D. Database creation is DBMS specific
18. Which of the following can you do with a JDBC 2.0 database driver that you cannot with a JDBC 1.x driver?
A. Batch multiple statements, to be sent to the database together
B. Scroll through result sets bi-directionally
C. Work with SQL3 data types directly
D. All of the above
19. A __________ result set has a cursor that moves both forward and backward and can be moved to a particular row
A. scrollable
B. nonscrollable
C. Unscrollable
20. The method___________ is designed for statements that produce a single result set, such as SELECT statement
A. executeUpdate
B. execute
C. Update
D. executeQuery
21. Which three of the following are classes of Java.rmi package?
A. Naming
B. MarshalledObject
C. RMISecurityManager
D. Remote
22. Which option of jar file indicates manifest file not created?
A. Jar M
B. Jar t
c. Jar m
D. Jar c
23. _______ option of Jar command makes a Java archive file.
A. JAR -c
B. JAR -m
C. JAR -v
D. JAR –f
24. Which command adds the file file.class to Xyz.jar?
A. jar – uf Xyz . jar file.class
B. jar – xf Xyz . jar
C. jar – tf Xyz . jar
25. Driver types are used to categorize the technology used to connect to the database.
A. True
B. False
26. This is an Application Programming Interface provided by Microsoft for access the database.It uses SQL as its database language.
A. JDBC
B. ODBC
27. JDBC is ODBC translated into an object-oriented interface that is natural for java programmers.
A. True
B. False
28. In this Data processing Model,the client communicates directly to the database server without the help of any middle-ware technologies or another server.
A. Two-tier Data processing Model
B. Three - tier Data processing Model
29. The Type 1 driver is also known as JDBC-ODBC bridge plus ODBC driver.
A. Translates JDBC calls into ODBC calls.
B. Translates JDBC calls into database=specific calls or native calls
C. Maps JDBC calls to the underlying "network" protocol, which in turn calls native methods on the server.
D. Directly calls RDBMS from client machine.
30. This method is used to execute INSERT, DELETE, UPDATE , and other SQL DDL such as CREATE, DROP Table.
A. executeUpdate();
B. execute();
C. executeQuery();
31. This method is used for retrieving a string value (SQL type VARCHAR) and assigning into java String object.
A. getVarchar();
B. getObject();
C. getString();
32. This method is used for retrieving the value from current row as object.
A. getRow();
B. getObject();
C. getString();
33. This object connects to a data source only to read data from a ResultSet or write data back to the data source.
A. A Connected RowSet.
B. A Disconnected RowSet.
34. A client application uses stored procedures increases the network traffic, but it reduces the number of times a database is accessed.
A. True
B. False
35. This parameter is used to pass values into a store procedure.The value of this parameter cannot changed or reassigned within the module and hence is constant.
A. IN
B. OUT
C. IN/OUT
36. OUT Parameter. - 3 choices.
A. pass out of procedure module
B. is a constant
C. is a variable
D. back to the calling block
37. This Parameter behaves like an initialized variable.
A. OUT
B. IN
C. IN/OUT
38. This object does not contain the stored procedure itself but contains only a call to the stored procedure.
A. CallableStatment
B. PreparedStatment
C. prepareCall();
39. This refers to the ability to check whether the cursor stays open after a COMMIT
A. Updatable
B. Holdable
C. Scrollable
40. The prepareStatment() method sends SQL query to the database. and this returns:
A. PrepareStatment Object
B. Callalbalestatment Object
C. PrepareCall () method.
41. The CallableStatment object contains the SQL statments.
A. True
B. False
42. A cursor that can only be used to process from the beginning of a ResultSet to the end of it.It is default type.
A. TYPE_SCROLL_SENSITIVE
B. TYPE_SCROLL_INSENSITIVE
C. TYPE_FORWARD_ONLY
43. A Rowset Object provides scrollability and updatability for any kind of DBMS or drivers.
A. True
B. False
44. A ResultSet object contains a set of rows from a result set or some other source of tabular data, like a file or spreadsheet.
A. true
B. false
45. Which class is a disconnected rowset.
A. A CachedRowSet class.
B. A JDBCRowSet class.
C. A WebRowSet class.
46. Which statments are true?
A. A RowSet has to be make scrollable and updatable at the time of creation.
B. Scrollability and Updatability of a RowSet is independent of the JDBC driver
C. A connect RowSet can read data from a non relational database source also.
D. A RowSet is a JavaBeans component which has to programmatically notify all registered event listener.
47. The Result Set can not be modified and hence, It is not updatable in any way.
A. CONCURENT_READ_ONLY
B. CONCURENT_UPDATABLE
48. This is the mechanism of encoding information in a secret coded form, intented only for the recipient to access the information.
A. Cryptography
B. Encryption
49. The term "encrypting " pertains to converting plaintext to ciphertext, which is again decrypted into usable plaintext.
A. True
B. False
50. This transforms the input, called the plaintext, to an output, known as ciphertext. this is known as Symmetric cryptography.
A. Hash Function
B. Secret key cryptography
C. Public Key cryptography
51. This is as asymmetric cryptography, It operates under two different keys.
A. Public Key cryptography
B. Hash Function
C. Secret key cryptography
52. This is algorithms that does not use any key, it is known as message digest.
A. Secret key cryptography
B. Public Key cryptography
C. Hash Function
53. Which statements are true?
A. The Tamper-proofing process verifies whether the data received by the receiver is the same data as sent by the sender.
B. Spoofing or identity interception, which means impersonating the identity of a different user and use it in an unauthorized way
C. Authentication is the process that provides tamper-proofing, while it is on the network.
54. The class is use to hash value of the specified data.
A. Message Digest
B. Signature
C. KeyPair Generator
D. KeyFactory
E. Certificate Factory
55. The 'Native API-Java/Party Java' is Driver Type
A. I
B. II
C. III
D. IV
56. The 'Native Protocol - All Java' is Driver Type
A. I
B. II
C. III
D. IV
57. Statement and PreparedStatement is inherited from Statement Interface. The CallableStatement is inherited from PreparedStatement interface.
A. True
B. False
58. This Method return an Integer value indicating the row count.
A. ExecuteQuery();
B. Execute();
C. ExecuteUpdate();
59. If row value is 0, this method has no effect.If row value is positive, the cursor is moved forward that many row.
A. relative(int row) method
B. absolute(int row) method.
60. Calling absolute(1) is equivalent to calling last()
A. True
B. False
61. Which statements are true? (3 choices)
A. In Scrollable ResultSet, the cursor is positioned on the first row.
B. A default ResultSet object is not updated and has a cursor that moves forward only.
C. The ResultSet should be compulsorily closed after a COMMIT statement.
D. Holdable refers to ability to check whether the cursor stays open after a COMMIT.
E. The createStatement method has two argurments namely resultSetType and resultSetConcurrency
62. Which statements are true? (3 choices)
A. The original message text has to be transmitted separately since the content of a digitally signed message is altered irreversibly.
B. A Certification authority creates a signed certificate by encrypting the digitally signature with its private key.
C. The digital signature and sender's public key are appended to end of a message.
D. A recipient decrypts a signed signature using its own public key.
E. The integrity of a message cannot be ensure while using message digests
63. This comprises the mapping of one or more permissions with a class.
A. Security Manager
B. Policy File
C. Access Controller
64. The class is use to produce a pair of public and private keys appropriate for a specified.
A. Signature
B. Message Digest
C. KeyPair Generator
D. KeyFactory
E. Certificate Factory
65. The class is used to sign and check the authenticity of digital signature
A. Message Digest
B. Signature
C. Certificate Factory
D. KeyFactory
E. KeyPair Generator
66. The class is used to transform opaque keys of type Key into key specifications and provide transparent representations of the underlying key material and vice versa.
A. Message Digest
B. KeyPair Generator
C. Signature
D. KeyFactory
E. Certificate Factory
67. The class is used to generate public key certificates.
A. Certificate Factory
B. KeyPair Generator
C. Message Digest
D. Signature
E. KeyFactory
68. This class is a database of keys and certificates
A. Algorithm Parameters
B. KeyStore
C. Key
D. KeySpec
69. this ensures that a user or a business organization or a program entity has performed a transaction.
A. Non-repudiation
B. Tampering
C. Integrity
D. Confidentiality
70. Data integrity is to protect data from getting tampered, while it is on the network.
A. True
B. False
71. This is a framework written in java to access and develop cryptographic functionality, and forms part of the java security API.
A. JCA
B. JCE
72. With this padding technique a short block is padded with a repeating byte.
A. DES
B. PKCS5
C. CBC
73. Single-bit ciphers are called:
A. Block cipher
B. Stream cipher
74. Cipher objects are created using this method of the cipher class.
A. getInstance();
B. init();
75. the cipher object is initialized by the init() method?
A. True
B. False
76. The Code : "DES/CBC/PKCS5Padding" is the form of
A. "mode/algorithm/padding"
B. "algorithm/mode/padding"
C. "algorithm/padding/mode"
D. "DeCrypto/Cipher/padding"
77. "(Only)algorithm" such as
A. "DES"
B. "PKCS5"
C. "CBE"
78. Most these implementations mix a random number, known as the "salt" with the password text to derive an encrypted key.
A. Encryption and Decryption
B. Key Agreement
C. Password Base Encryption
79. Single bits or a block of bits can be encrypted into cipher blocks
A. True
B. False
80. In this Environment, the java application is the client and DBMS is the database server.
A. Three-Tier JDBC
B. Two-Tier JDBC

 

Đáp án:

1-B, 2-4,3-B,4-B,5-B,6-B,7-B, 8-C, 9-C, 10-C, 11-B, 12-C, 13-D, 14-B, 15-C, 16-B, 17-B, 18-D, 19-D, 20-D, 21-abc, 25-a, 26-b, 26-a, 27-a, 28-a, 29-a, 30-a, 31-c, 32-b, 33-a, 34-b, 35-a, 36-ad, 37-c, 38-a, 39-b, 40-a, 41-a, 42-c, 43-a, 44-b, 45a, 46b, 47a, 48a, 49a, 50b, 51a, 52c, 53a, 54a, 55a, 56c, 57a, 58c, 59a, 60b, 61ade, 62bce, 63b, 64c, 65b, 66d, 67a, 68b, 69a, 70a, 71a, 72b, 73b, 74a, 75a, 76b, 77a, 78c, 79a, 80b. 

Thursday, September 18, 2014

Tài liệu cơ bản về XML (sưu tầm)

Đây là một tài liệu rất cơ bản và chi tiết về XML

Can ban - xml

(sưu tầm từ nguồn Internet)

Thursday, September 11, 2014

JSF and Strut questions and anwsers


  1. Struts was first developed

    1. in an online exchange between several open source developers

    2. over a long holiday weekend(TRUE)

    3. as a commercial package



  2. The reset method on an ActionForm

    1. Sets all properties to their initial value

    2. Sets all properties to null

    3. Repopulates all properties from the request parameters

    4. None of the above(TRUE)



  3. Each Struts Action element is uniquely identified by its

    1. Input attribute

    2. Name attribute

    3. Page attribute

    4. Path attribute(TRUE)



  4. The name of the Application Resources file is set by the servlet init-param named

    1. Application(TRUE)

    2. Resources

    3. ApplicationResources

    4. messages



  5. The validating init-param of the ActionServlet is used to

    1. Bypass calls to the ActionForm validate method

    2. Bypass validation of the Struts configuration file(TRUE)

    3. Generate an error message if an unknown message key is used



  6. To specify an ActionMapping to use when a request doesn't match any other mapping, you can

    1. Use an asterisk for the path property

    2. Set the "default" property of the mapping to "true"

    3. Set the "unknown" property of the mapping to "true"(TRUE)

    4. Set the "missing" init-param of the ActionServlet to the mapping's path



  7. In Struts 1.1, you can change how Struts populates a form by

    1. Overriding the populate method of the ActionForm

    2. Overriding the processPopulate method of the Request Processor(TRUE)

    3. Overriding the populateBean method of the ActionMapping



  8. The < bean:write > tag is:

    1. Always converts HTML markup to entity equivalents, like &lt;

    2. Never converts HTML markup to entity equivalents

    3. Converts markup when filter=true(TRUE)

    4. Converts markup when markup=false



  9. From a MVC perspective, Struts provides the

    1. Model

    2. View

    3. Controller(TRUE)



  10. Struts Framework is well suited for application of ____ size.

    1. Small

    2. Any(TRUE)

    3. Average

    4. Very small



  11. MVC is :

    1. Mode-View-Controller

    2. Model-View-Converter

    3. Model-Viewer-Controller

    4. Model-View-Controller(TRUE)



  12. What is Action Class ?

    1. The Action Class is a wrapper around the business logic and is a part of Model(TRUE)

    2. Nothing special about the Action class

    3. Action Class is a wrapper around the Internet logic

    4. None of the above



  13. An ActionForm is a JavaBean which extends the:

    1. struts.action.ActionForm(TRUE)

    2. apache.struts.action.ActionForm

    3. action.ActionForm

    4. ActionForm



  14. Use the following command (tag) to display the error on the jsp page:

    1. < html:errors/ >

    2. < html:errors/ >(TRUE)

    3. < errors / >

    4. < html=errors/ >



  15. What of following features can _not_ be configured in the JSF configuration file?

    1. Navigation rules

    2. Managed Beans

    3. Custom components

    4. Application Name(TRUE)



  16. In JSF - Which tag must enclose all other tags on a Faces JSP page?

    1. < f:faces >

    2. < f:view >(TRUE)

    3. < h:jsf >

    4. < h:view >



  17. In JSF - Why does the HtmlForm component render a <hidden> field?

    1. Command events

    2. Submit events

    3. Action events(TRUE)

    4. Click events



  18. In JSF - Why does the HtmlForm component render a < hidden > field

    1. To keep track of its identifier

    2. To keep track of the components in tree

    3. To set its submitted property(TRUE)

    4. For JavaScript integration



  19. What are the main features of JSF ? ( Choose many )

    1. Page navigation specification(TRUE)

    2. Standard user interface components like input fields, buttons, and links(TRUE)

    3. Read xml file

    4. Easy error handling(TRUE)



  20. In JSF - Components can be nested within another component

    1. True(TRUE)

    2. False




Next 20 -->

  1. Which one of the following tags renders a single radio button?

    1. <h:selectBooleanCheckbox>

    2. <h:selectOneRadio>

    3. <h:selectOneCheckbox>

    4. <h:selectManyCheckbox>



  2. The tag library that allows you to keep common content in a Web application, at a common location and insert it where necessary is

    1. HTML tag library

    2. Logic tag library

    3. Bean tag library

    4. Template tag library



  3. The tag used to create an input field that is not visible to the user is _______________.

    1. <h:inputSecret>

    2. <h:inputHidden>

    3. <h:inputPassword>

    4. <h:inputText>



  4. ______________ class is used to uniquely represent a locale of a country.

    1. faces.render.Locale

    2. util.Locale

    3. faces.context.Locale



  5. Creating and using a custom converter requires implementing _____________ and _____________ methods provided by Converter interface.

    1. getObject()

    2. getAsObject()

    3. getAsString()

    4. getString()



  6. It is possible to have more than one Faces configuration file.

    1. True

    2. False



  7. ________ classplays the role of the controller and is responsible for handling all the requests.

    1. Action

    2. ActionServlet

    3. RequestProcessor

    4. Plugin



  8. The tag used to create a text box to accept a password is _______________.

    1. <h:inputSecret>

    2. <h:inputHidden>

    3. <h:inputPassword>

    4. <h:inputText>



  9. Which of the following UI Component acts as a container for all other components?

    1. UIParameter

    2. UIForm

    3. UIViewRoot

    4. UISelectItem



  10. Which of the following statements are true about the reset() method of ActionForm class?

    1. Sets all properties to their initial value

    2. Sets all properties to null

    3. Repopulates all properties from the request parameters

    4. None of the above



  11. _______________________ declares a set of rules that define the next view for the user based on his/her actions.

    1. JSF Navigation Model

    2. JSF View Model

    3. JSF Forward Model

    4. JSF Model



  12. The file that provides a set of utility classes and interfaces that handle data structures used to store data in an application is _________.

    1. commons-beanutils.jar

    2. commons-collections.jar

    3. commons-digester.jar

    4. commons-logging.jar



  13. Which method of ActionServlet class maps the servlet name to a URL in the Web application?

    1. init()

    2. save()

    3. addmapping()

    4. addServletMapping()



  14. The JSF tag used to show all the error messages in a JSP page is ____________.

    1. <h:message>

    2. <h:messages>

    3. <f:messages>

    4. <f:message>



  15. Which one of the following JSF expressions, references an application's context path?

    1. #{contextPath}

    2. #{requestContextPath}

    3. #{facesContext.externalContext.requestContextPath}

    4. ${request.contextPath}



  16. Each Struts Action element is uniquely identified by its __________.

    1. Input attribute

    2. Name attribute

    3. Path attribute

    4. Page attribute



  17. Which one of the following events is generated by the <h:commandButton> tag of JSF ?

    1. Command event

    2. Submit event

    3. Action event

    4. Click event



  18. Which one of the following Action classes provides a mechanism for switching between modules in a modularized Struts application?

    1. SwitchAction

    2. DispatchAction

    3. IncludeAction

    4. LocaleAction



  19. The Struts class which handles the actual execution of the request is ________.

    1. ActionForward

    2. Action

    3. RequestProcessor

    4. ActionServlet



  20. The Struts tag used to display the error in the JSP page is ______________.

    1. <html:errors/>

    2. <html:errors>

    3. <errors>

    4. <html=errors>




Next 13 (sun)

  1. Struts was first developed

    1. in an online exchange between several open source developers

    2. over a long holiday weekend

    3. as a commercial package



  2. The reset method on an ActionForm

    1. Sets all properties to their initial value

    2. Sets all properties to null

    3. Repopulates all properties from the request parameters

    4. None of the above (do nothing)



  3. Each Struts Action element is uniquely identified by its

    1. Input attribute

    2. Name attribute

    3. Page attribute

    4. Path attribute



  4. The name of the Application Resources file is set by the servlet init-param named

    1. application

    2. resources

    3. ApplicationResources

    4. messages



  5. The validating init-param of the ActionServlet is used to

    1. Bypass calls to the ActionForm validate method

    2. Bypass validation of the Struts configuration file

    3. Generate an error message if an unknown message key is used



  6. To specify an ActionMapping to use when a request doesn't match any other mapping, you can

    1. Use an asterisk for the path property

    2. Set the "default" property of the mapping to "true"

    3. Set the "unknown" property of the mapping to "true"

    4. Set the "missing" init-param of the ActionServlet to the mapping's path



  7. If you have created a custom ActionMapping subclass with the property "service", you can initialize the value to "selectRecord" using

    1. <init-property name="service" value="selectRecord"/>

    2. <set-property property="service" value="selectRecord"/>

    3. <put-field key="service" content="selectRecord"/>



  8. In Struts 1.1, you can change how Struts populates a form by

    1. Overriding the populate method of the ActionForm

    2. Overriding the processPopulate method of the Request Processor

    3. Overriding the populateBean method of the ActionMapping



  9. The <bean:write> tag is:

    1. Always converts HTML markup to entity equivalents, like &lt;

    2. Never converts HTML markup to entity equivalents

    3. Converts markup when filter=true

    4. Converts markup when markup=false



  10. To prevent possible security issues with the <html:password> tag, you should

    1. Call the reset method if validation fails

    2. Set the tag's redisplay property to false

    3. Set the tag's reset property to false

    4. Use a plain html tag instead



  11. To localize Tiles, you can

    1. Create separate configuration files for each locale

    2. Specify an locale for a definition

    3. Either A or B



  12. To localize Validator forms, you can

    1. Create separate configuration files for each locale

    2. Specify a locale for a form-set

    3. Either A or B



  13. From a MVC perspective, Struts provides the

    1. Model

    2. View

    3. Controller




Next 20 -->> 20 question_3

Translate