D) in scraps of discarded food?
B. Arrow keys
Good luck! :)
Answer:
Java Socket programming is used for communication between the applications running on different JRE.
Java Socket programming can be connection-oriented or connection-less.
Socket and ServerSocket classes are used for connection-oriented socket programming and DatagramSocket and DatagramPacket classes are used for connection-less socket programming.
The client in socket programming must know two information:
IP Address of Server, and
Port number.
Here, we are going to make one-way client and server communication. In this application, client sends a message to the server, server reads the message and prints it. Here, two classes are being used: Socket and ServerSocket. The Socket class is used to communicate client and server. Through this class, we can read and write message. The ServerSocket class is used at server-side. The accept() method of ServerSocket class blocks the console until the client is connected. After the successful connection of client, it returns the instance of Socket at server-side.
Explanation:
Creating Client:
import java.io.*;
import java.net.*;
public class MyServer {
public static void main(String[] args){
try{
ServerSocket ss=new ServerSocket(6666);
Socket s=ss.accept();//establishes connection.
DataInputStream dis=new DataInputStream(s.getInputStream());
Answer:
Option 1 is the correct answer for the above question.
Explanation:
Encapsulation means rapper the data or variable or method on some pack and denies to give direct access for any private data. The above question wants to ask about the Encapsulation. The option 1 is correct for its because this option suggests a scenario, where a class field is declared as private and we know that private data members of the class can not be accessed by outside the class. It can access only the inside of the class. So it proves both the property of encapsulation one is to rapper the data and the other is to deny the directly accessed outside. So this option is correct while the other is not because--
- Option 2 states that another class is extended by the base class which is not the property of encapsulation.
- Option 3 states that a sub-type object can be referred by the variable of super-type which is also not the property of encapsulation.
- Option 4 states that a class is contained by the other class which does not hold both the property of encapsulation.