What is the main difference between a scripting language and a compiled language?
A Speed of execution
B Syntax
C Memory usage
D Error handling
Scripting languages are generally slower than compiled languages because they are interpreted at runtime, whereas compiled languages are converted into machine code before execution, making them faster in terms of execution speed.
Which of the following is used to connect to a database in Python?
A database
B DBConnect
C sqlite3
D sql
In Python, the sqlite3 module is used to connect to SQLite databases. It allows Python programs to interact with relational databases, enabling queries and manipulation of data stored in databases.
Which protocol is used for transferring web pages across the internet?
A HTTP
B FTP
C SMTP
D POP3
HTTP (HyperText Transfer Protocol) is the protocol used for transferring web pages and other resources across the internet. It defines how clients (like browsers) request web pages and how servers respond with content.
In Java, which method is used to establish a connection to a database?
A connect()
B getConnection()
C open()
D database()
In Java, the getConnection() method of the DriverManager class is used to establish a connection to a database. It requires the database URL, username, and password for authentication.
Which of these is a key advantage of compiled languages over scripting languages?
A Easier syntax
B Platform independence
C No need for interpretation
D Faster execution
Compiled languages are faster because the code is translated directly into machine code before execution, allowing programs to run more quickly. In contrast, scripting languages are interpreted line by line, which adds overhead during runtime.
In C, which function is used to establish a network connection?
A connect()
B socket()
C send()
D bind()
In C, the connect() function is used to establish a connection to a remote server using a socket. It links a socket with a specific address and port number for communication over a network.
What does the import statement do in Python?
A Imports a variable
B Imports a function
C Imports a module
D Imports a file
In Python, the import statement is used to include a module in the current script, allowing you to use the functions and classes defined in that module. It is essential for code organization and reuse.
Which of the following is used for network programming in Java?
A Socket
B FileReader
C Server
D Buffer
In Java, the Socket class is used to establish a connection to a remote server or a local machine via TCP/IP. It provides methods for reading from and writing to a network socket.
Which of these is a compiled language?
A Python
B JavaScript
C C++
D Ruby
C++ is a compiled language, meaning its source code is translated into machine code using a compiler before execution. This typically results in faster execution compared to interpreted languages like Python or Ruby.
Which of these is used to send a query to a database in SQL?
A send()
B query()
C execute()
D fetch()
In SQL, the execute() method is used to send a query to the database for execution. This method is part of the database connection object, allowing you to run SQL commands like SELECT, INSERT, UPDATE, etc.
What is the main advantage of scripting languages over compiled languages?
A Faster execution
B Easier to debug
C More efficient memory usage
D Better error handling
Scripting languages are often easier to debug because they are interpreted at runtime. Errors are detected immediately, allowing for rapid troubleshooting and adjustments. Compiled languages require recompilation after each change.
What does the send() function do in network programming?
A Sends data over a socket
B Receives data from a socket
C Connects to a server
D Closes a connection
In network programming, the send() function is used to send data over an open socket connection. It transmits the data to the specified remote server or client over the network.
Which of these is the correct way to connect to a MySQL database in Python?
A mysql.connect()
B mysqlDB.connect()
C mysql.connector.connect()
D db.connect()
In Python, the mysql.connector.connect() method is used to establish a connection to a MySQL database. It requires the database host, username, password, and database name for authentication.
Which of the following protocols is used for secure communication over the web?
A FTP
B HTTP
C SMTP
D HTTPS
HTTPS (HyperText Transfer Protocol Secure) is the secure version of HTTP. It encrypts data between the client and the server using SSL/TLS, ensuring that sensitive data such as passwords and credit card information is transmitted securely.
Which module in Python is used to perform networking tasks like socket communication?
A os
B io
C sys
D socket
In Python, the socket module is used to perform low-level networking tasks. It provides the necessary functions for creating, connecting, and managing network sockets for communication between different systems over the internet.