<?xml version="1.0"?>
<rss version="2.0">
   <channel>
      <title>Làm lại Nhóm 6 - 9999 - Java chiều 2/10 by Hồ Quảng Lợi</title>
      <link>https://padlet.com/horin123456789/h3b8z7rp2lmy7dz8</link>
      <description>Được tạo từ những giấc mơ lớn</description>
      <language>en-us</language>
      <pubDate>2021-10-02 06:44:46 UTC</pubDate>
      <lastBuildDate>2025-10-25 19:58:24 UTC</lastBuildDate>
      <webMaster>hello@padlet.com</webMaster>
      <image>
         <url>https://padlet.net/icons/png/1f970.png</url>
      </image>
      <item>
         <title>Câu 1:Trong java có những kiểu dữ liệu nào? ví dụ?</title>
         <author>horin123456789</author>
         <link>https://padlet.com/horin123456789/h3b8z7rp2lmy7dz8/wish/1785573795</link>
         <description><![CDATA[<div><strong><br>*Kiểu Primitive</strong></div><div><strong>1. Boolean</strong></div><div>Đây là kiểu dữ liệu có bộ nhớ lưu trữ nhỏ nhất, chỉ có 1 bit. Kiểu dữ liệu này được dùng để lưu trữ hai trạng thái true hoặc false Giá trị mặc định là false.</div><div>-Ví dụ: boolean extractall = true</div><div><strong>2. Char</strong></div><div>Kiểu dữ liệu này có thể dùng để lưu kí tự hoặc số nguyên không âm, có kích thước 2 byte. Giá trị nhỏ nhất là '\u0000' (hoặc 0) và giá trị lớn nhất là '\uffff' (hoặc 65,535).</div><div>-Ví dụ: char name ='A' Câu hỏi đặt ra là vì sao kiểu dữ liệu char có giá trị mặc định là '\u0000' và bộ nhớ là 2 byte? Lý do là vì Java sử dụng bảng mã Unicode. Trong Unicode mỗi ký tự giữ 2 byte, do đó Java cũng cấp cho kiểu dữ liệu char bộ nhớ 2 byte.</div><div><strong>3. Byte</strong></div><div>Kiểu dữ liệu này dùng để lưu số nguyên (âm hoặc dương), có kích thước 1 byte. Giá trị nhỏ nhất là -128 (-2^7) và giá trị lớn nhất là 127 (2^7 -1) Giá trị mặc định là 0.</div><div>-Ví dụ: byte x = 1 , byte y = -1</div><div><strong>4. Short</strong></div><div>Dùng để lưu dữ liệu có kiểu số nguyên, nhưng kích cỡ lớn hơn byte. Bộ nhớ kiểu dữ liệu này là 2 byte. Giá trị nhỏ nhất là -32,768 (-2^15) và giá trị lớn nhất là 32,767 (2^15 -1) Giá trị mặc định là 0.</div><div>-Ví dụ: short t = 50, short z = -50</div><div><strong>5. Int</strong></div><div>Đây cũng là kiểu dữ liệu dùng để lưu kiểu số nguyên, kích cỡ 4 byte (lớn hơn byte và short). Giá trị nhỏ nhất là - 2,147,483,648.(-2^31) và giá trị lớn nhất là 2,147,483,647 (2^31 -1) Thông thường, int được sử dụng làm kiểu dữ liệu mặc định cho các giá trị nguyên. Giá trị mặc định là 0.</div><div>-Ví dụ: int a = 500, int b = -500</div><div><strong>6. Long</strong></div><div>Kiểu dữ liệu dùng để lưu số nguyên lớn nhất là Long. Kích cỡ của nó lên đến 8 byte. Giá trị nhỏ nhất là -9,223,372,036,854,775,808.(-2^63) và lớn nhất là 9,223,372,036,854,775,807 (2^63 -1) Kiểu này được sử dụng khi cần một dải giá trị rộng hơn int. Giá trị mặc định là 0L.</div><div>-Ví dụ: long a = 100000L, int b = -100000L</div><div><strong>7. Float</strong></div><div>Float là kiểu dữ liệu lưu số thực, kích cỡ 4 byte. Giá trị mặc định là 0.0f. Kiểu Float không bao giờ được sử dụng cho các giá trị chính xác như currency.</div><div>-Ví dụ: float jpy = 22.2f</div><div><strong>8. Double</strong></div><div>Double cũng là kiểu dữ liệu để lưu số thực, nhưng kích thước dữ liệu lớn hơn Float. Bộ nhớ của nó là 8 byte. Thông thường, kiểu dữ liệu này được sử dụng làm kiểu mặc định cho các giá trị decimal. Kiểu double cũng không bao giờ được sử dụng cho các giá trị chính xác như currency. Giá trị mặc định là 0.0d.</div><div>-Ví dụ: double ct = 676.7</div><div>*<strong>Kiểu Non - Primitive</strong></div><div>Trong Java tồn tại kiểu biến đối tượng, được tạo bằng cách sử dụng các constructor đã được định nghĩa của các class. Chúng được sử dụng để truy cập các đối tượng. Những biến này được khai báo ở kiểu cụ thể và không thể thay đổi được</div><div><br>Giá trị mặc định của kiểu biến đối tượng là null. Có thể sử dụng biến đối tượng để tham chiếu tới bất kỳ đối tượng nào trong kiểu được khai báo hoặc bất kỳ kiểu tương thích nào.</div>]]></description>
         <enclosure url="https://padlet-uploads.storage.googleapis.com/1367757165/20058c09d73ad97d3ef766fb8011a564/B_i_2_C_c_ki_u_d__li_u_trong_java_810x424.jpg" />
         <pubDate>2021-10-02 06:59:53 UTC</pubDate>
         <guid>https://padlet.com/horin123456789/h3b8z7rp2lmy7dz8/wish/1785573795</guid>
      </item>
      <item>
         <title>Câu 2: Phân biệt biến và hằng trong Java. Cho ví dụ minh họa. Cần lưu ý gì khi đặt tên?</title>
         <author>Trquynh21</author>
         <link>https://padlet.com/horin123456789/h3b8z7rp2lmy7dz8/wish/1785594442</link>
         <description><![CDATA[<div><strong>*Phân biệt biến và hằng:</strong><br>Hằng: - Giá trị của hằng không thể thay đổi trong quá trình thực hiện chương trình.<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - Cách khai báo hằng:&nbsp; const&lt;tên hằng&gt;=&lt;giá trị của hằng&gt;;<br>Vd: Const pi = 3.14;<br>Biến: - Giá trị của biến có thể thay đổi trong quá trình thực hiện chương trình.<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- Cách khai báo biến: Var&lt;tên biến&gt;:&lt;kiểu dữ liệu&gt;;<br>Vd: Var a,b:integer;<br><strong>* Những lưu ý khi đặt tên:</strong><br>- Đặt tên biến:<br><strong>Quy tắc 1</strong>: Ký tự bắt đầu của tên biến phải bắt đầu bằng chữ cái, hoặc dấu gạch dưới(_), hoặc ký tự đô la($).<br><strong>Quy tắc 2</strong>: Không được có khoảng trắng giữa các ký tự biến.<br><strong>Quy tắc 3</strong>: Không chứa ký tự đặc biệt bên trong biến như !@#%^&amp;*.<br><strong>Quy tắc 4</strong>: Không được đặt tên biến trùng với keyword.</div>]]></description>
         <enclosure url="https://padlet-uploads.storage.googleapis.com/1367760931/ff23e0dc400f27b2207bd9e78f39c4d2/th__4_.jfif" />
         <pubDate>2021-10-02 07:33:09 UTC</pubDate>
         <guid>https://padlet.com/horin123456789/h3b8z7rp2lmy7dz8/wish/1785594442</guid>
      </item>
      <item>
         <title>Bảng phân công nhiệm vụ: </title>
         <author>horin123456789</author>
         <link>https://padlet.com/horin123456789/h3b8z7rp2lmy7dz8/wish/1785597128</link>
         <description><![CDATA[<div>-Câu 1: Lợi<br>-Câu 2: Quỳnh<br>-Câu 3: Phong<br>-Câu 4: Duy<br>-Câu 5: Phú</div>]]></description>
         <enclosure url="" />
         <pubDate>2021-10-02 07:37:11 UTC</pubDate>
         <guid>https://padlet.com/horin123456789/h3b8z7rp2lmy7dz8/wish/1785597128</guid>
      </item>
      <item>
         <title>Câu 3 : Có bao nhiêu cách ép kiểu trong Java ? Cho ví dụ cụ thể?</title>
         <author>phongle25402</author>
         <link>https://padlet.com/horin123456789/h3b8z7rp2lmy7dz8/wish/1785598246</link>
         <description><![CDATA[<div>- Có 2 cách :<br>+&nbsp;<strong>Nới rộng (widening):</strong> Là quá trình làm tròn số từ kiểu dữ liệu có kích thước nhỏ hơn sang kiểu có kích thước lớn hơn. Kiểu biến đổi này không làm mất thông tin.<br><br>- <strong>Ví dụ : <br>public</strong> <strong>class</strong> TestWidening {</div><div><strong>public</strong> <strong>static</strong> <strong>void</strong> main(String[] args) {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; <strong>int</strong> i = 100;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; <strong>long</strong> l = i;&nbsp; &nbsp; // không yêu cầu chỉ định ép kiểu</div><div>&nbsp; &nbsp; &nbsp; &nbsp; <strong>float</strong> f = l; &nbsp; // không yêu cầu chỉ định ép kiểu</div><div>&nbsp; &nbsp; &nbsp; &nbsp; System.out.println("Giá trị Int: " + i);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; System.out.println("Giá trị Long: " + l);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; System.out.println("Giá trị Float:&nbsp; " + f);</div><div>&nbsp; &nbsp; }</div><div>}<br>Kết quả :&nbsp;</div><div>Giá trị Int : 100<br>Giá trị Long: 100</div><div>Giá trị Float : 100.0<br><br>+&nbsp;<strong>Thu hẹp (narrowwing):</strong> Là quá trình làm tròn số từ kiểu dữ liệu có kích thước lớn hơn sang kiểu có kích thước nhỏ hơn. Kiểu biến đổi này có thể làm mất thông tin như ví dụ ở trên. Chuyển kiểu loại này không thể thực hiện ngầm định bởi trình biên dịch, người dùng phải thực hiện chuyển kiểu tường minh.<br><br>- <strong>Ví dụ : </strong><br><strong>public</strong> <strong>class</strong> TestNarrowwing {</div><div><strong>public</strong> <strong>static</strong> <strong>void</strong> main(String[] args) {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; <strong>double</strong> d = 100.04;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; <strong>long</strong> l = (<strong>long</strong>) d; // yêu cầu chỉ định kiểu dữ liệu (long)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; <strong>int</strong> i = (<strong>int</strong>) l; // yêu cầu chỉ định kiểu dữ liệu (int)</div><div>&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; System.out.println("Giá trị Double: " + d);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; System.out.println("Giá trị Long: " + l);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; System.out.println("Giá trị Int:&nbsp; " + i);</div><div>&nbsp;</div><div>&nbsp; &nbsp; }</div><div>}</div><div>Kết quả :&nbsp;<br>Giá trị Double : 100.04<br>Giá trị Long : 100<br>Giá trị Int : 100<br><br></div>]]></description>
         <enclosure url="https://padlet-uploads.storage.googleapis.com/1367758217/0fce7e2dd3b5302682daf0a4950f99d3/download.jfif" />
         <pubDate>2021-10-02 07:38:54 UTC</pubDate>
         <guid>https://padlet.com/horin123456789/h3b8z7rp2lmy7dz8/wish/1785598246</guid>
      </item>
      <item>
         <title>Câu 5: Cách nhập xuất dữ liệu trong JAVA:</title>
         <author>minhduy1042002</author>
         <link>https://padlet.com/horin123456789/h3b8z7rp2lmy7dz8/wish/1785600075</link>
         <description><![CDATA[<div><strong>Có 3 cách để tiến hành nhập liệu từ bàn phím:</strong><br>- Cách đầu tiên là sử dụng lớp <strong>BufferReader</strong><br>- Cách 2 là sử dụng <strong>JOptionPane</strong><br>- Cách 3 là sử dụng lớp <strong>Scanner </strong>(hay dùng)<br><strong>1.Sử dụng lớp BufferReader.</strong><br>BufferReader là một lớp dùng để đọc dữ liều từ bàn phím hay từ file.</div><div>Có thể dùng lớp này để đọc một <strong>chuỗi</strong> một <strong>mảng</strong> hoặc một <strong>kí tự</strong>.</div><div><em>Ví dụ:</em><br><br>import java.io.BufferedReader;<br>import java.io.IOException;<br>import java.io.InputStreamReader;<br><br>public class GetInputFromKeyboard&nbsp;</div><div>{<br>&nbsp; &nbsp; &nbsp; &nbsp; public static void main(String[] args)&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Tạo một đối tượng BufferedReader<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BufferedReader dataIn = new BufferedReader(new<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; InputStreamReader( System.in) );<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Biến name<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; String name = "";<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println("Please Enter Your Name:");<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Tiến hành đọc từ bàn phím<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;name = dataIn.readLine();<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; catch( IOException e )</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Error!");<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // hiển thị tên<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Hello " + name +"!");<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br><br>}<br><br>Tham số đầu vào của BufferReader có thể là InputStreamReader hoặc FileReader (Dùng để đọc file).<br><strong><em>Một số phương thức của lớp BufferReader:</em></strong><br>- <strong>read()</strong> : đọc một kí tự.<br>- <strong>readLine()</strong> : đọc một dòng text.<br>==========================================================================================<br>2. Sử dụng JOptionPane:<br>JOptionPane là một lớp thừa kế từ lớp JComponent.</div><div>Khi biên dịch program thì nó sẽ hiện lên một dialog box cho phép cho ta nhập dữ liệu.<br><em>ví dụ:</em><br>import javax.swing.JOptionPane;<br>public class InputFromKeyboardJOptionPane</div><div>{<br>&nbsp; &nbsp; &nbsp; public static void main(String[] args)</div><div>&nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; String name = "";<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name=JOptionPane.showInputDialog("Please enter your name");<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; String msg = "Hello " + name + "!";<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JOptionPane.showMessageDialog(null, msg);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println("Name is:"+msg);<br>&nbsp; &nbsp; &nbsp; }<br><br>}<br><br><strong><em>Một số phương thức của JOptionPane:</em></strong><br>- <strong>showConfirmDialog()</strong> : Hiển thị một câu hỏi lựa chọn giống như yes no cancel<br>- <strong>showInputDialog()</strong> : Hiển thị box nhập<br>- <strong>showMessageDialog()</strong> : Báo cho người dùng một sự kiện vừa xảy ra.<br><br></div><div>=======================================================================================================<br><strong>3. Dùng lớp Scanner:</strong><br>Scanner là một lớp mới có(từ java 5 hay 6, những phiên bản 3 thì chưa có).</div><div>Scanner hơn hẳn những lớp trước là vì nó phân loại đc dữ liệu mà người dùng nhập vào cho nó: có thể đọc kiểu int hay float, double,..<br><em>Ví dụ:</em><br>import java.util.Scanner;<br><br>public class GetInputFromKeyboard</div><div>{<br>&nbsp; &nbsp; public static void main(String[] args)&nbsp;</div><div>&nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Scanner scanIn=new Scanner(System.in); // Tạo một đối tượng Scanner<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;String name = ""; // Biến Tên<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int age; // Biến Tuổi<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Nhap Ten va Tuoi cua ban:");<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;try &nbsp; // Tiến hành đọc từ bàn phím</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name = scanIn.nextLine();<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; age=scanIn.nextInt();<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;catch( IOException e )</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Error!");<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br>&nbsp; &nbsp; System.out.println("Name is" + name +"!");<br>&nbsp; &nbsp; System.out.println("Age is" + age +"!");<br>&nbsp; &nbsp; &nbsp;}<br><br>}<br><br><strong><em>Một số phương thức:</em></strong></div><div>- <strong>next()</strong> //dùng cho String<br>- <strong>nextInt()</strong><br>- <strong>nextFloat()</strong><br>- <strong>nextBoolean()</strong><br>- <strong>nextByte()</strong><br>-<strong> nextLine()<br></strong><br></div>]]></description>
         <enclosure url="" />
         <pubDate>2021-10-02 07:41:52 UTC</pubDate>
         <guid>https://padlet.com/horin123456789/h3b8z7rp2lmy7dz8/wish/1785600075</guid>
      </item>
      <item>
         <title>Câu 4: Trong java có những loại toán tử nào?</title>
         <author>minhphu7902</author>
         <link>https://padlet.com/horin123456789/h3b8z7rp2lmy7dz8/wish/1785609951</link>
         <description><![CDATA[<div>Toán tử trong java là một ký hiệu được sử dụng để thực hiện một phép tính/chức năng nào đó. Java cung cấp các dạng toán tử sau:<br><br></div><ul><li>Toán tử Đơn</li><li>Toán tử Toán học</li><li>Toán tử Dịch chuyển</li><li>Toán tử Quan hệ</li><li>Toán tử Bit</li><li>Toán tử Logic</li><li>Toán tử 3 Ngôi (Ternary)</li><li>Toán tử gán</li></ul><div>Ví dụ:<br>1. Toán tử đơn: ++, –, ~, !&nbsp;<br><br>class OperatorExample{ &nbsp;</div><div><br>&nbsp; public static void main(String args[]){ &nbsp;</div><div><br>&nbsp; &nbsp; int x=10; &nbsp;</div><div><br>&nbsp; &nbsp; System.out.println(x++);//10 (11) &nbsp;</div><div><br>&nbsp; &nbsp; System.out.println(++x);//12 &nbsp;</div><div><br>&nbsp; &nbsp; System.out.println(x--);//12 (11) &nbsp;</div><div><br>&nbsp; &nbsp; System.out.println(--x);//10 &nbsp;</div><div><br>&nbsp; }</div><div><br>} &nbsp;<br>Kết quả: 10 12 12 10<br><strong><br>2. Ví dụ về toán tử toán học trong Java<br></strong><br></div><pre>class OperatorExample{  
  public static void main(String args[]){  
    int a=10;  
    int b=5;  
    System.out.println(a+b);//15  
    System.out.println(a-b);//5  
    System.out.println(a*b);//50  
    System.out.println(a/b);//2  
    System.out.println(a%b);//0  
  }
}  </pre><div>Kết quả: 15 5 50 2 0<br><strong><br>3. Ví dụ về toán tử Dịch chuyển trong JAVA<br></strong><br></div><pre>class OperatorExample{  
  public static void main(String args[]){  
    System.out.println(10&lt;&lt;2);//10*2^2=10*4=40  
    System.out.println(10&lt;&lt;3);//10*2^3=10*8=80  
    System.out.println(20&lt;&lt;2);//20*2^2=20*4=80  
    System.out.println(15&lt;&lt;4);//15*2^4=15*16=240  
  }
}  </pre><div>Kết quả : 40 80 80 240</div>]]></description>
         <enclosure url="" />
         <pubDate>2021-10-02 07:56:37 UTC</pubDate>
         <guid>https://padlet.com/horin123456789/h3b8z7rp2lmy7dz8/wish/1785609951</guid>
      </item>
   </channel>
</rss>
