How to Find UID and GID

The Linux and Unix operating systems use the UID — user ID — to identify a particular user. The GID, or group ID, is used to identify a group. Each user will have a single, unique UID and a primary GID. The user can belong to several secondary groups and each secondary group will have a unique GID. The “id” command can be used to show the UID and GIDs for a particular user. The root (super) user can view the UID and GID for any user. If you do not have root privileges, you can only view your own UID and GID.

Step 1

Open a terminal window. The terminal application is usually found in the “Accessories,” “Utilities” or “Tools” section of the main “Programs” or “Applications” menu.

Step 2

Type the command “su” to become the root user. Skip this step if you do not have root user privileges or want to find the UID or GID for your own account.

Step 3

Type the command “id -u” to find the UID for a particular user. Replace “” with the user’s Unix or Linux username.

Step 4

Type the command “id -g” to find the primary GID for a particular user. Replace “” with the user’s Unix or Linux username.

Step 5

Type the command “id -G” to list all the GIDs for a particular user. Replace “” with the user’s Unix or Linux username.

Step 6

Type the command “exit” to close the root user session.

How to View Linux Login History

Linux is a multi-user operating system, meaning that more than one person can be logged into a computer at the same time. To see the login history of all the computer’s users, use the “last” command in the Linux terminal window. Variations of the “last” command can show you the history of one particular user, or the IP addresses of any computers used to log in from, provided the Linux system can be accessed by remote computers.

Step 1

Open the Linux terminal window. The terminal window can be found under the “System Tools,” “Utilities” or “Accessories” section of the main menu depending on your distribution.

Step 2

Type the “last” in the terminal window and press Enter to see the login history of all users.

Step 3

Type the command “last” in the terminal window, replacing “” with the username for a particular user.

Step 4

Type the command “last -a” to see the login history and the IP addresses of the computers used.

Step 5

Type “exit” and press the Enter key to close the terminal window.

How to disable PHP error logs

By default, PHP errors and warnings generated by your websites are logged in error_log files in the directory where your PHP files are located. The PHP error_log files can grow to a large size.

If you do not need the error_log file you can disable PHP error logging using one of the three ways listed below:

PHP Selector in cPanel — Recommended

  1. Log in to cPanel.
  2. Click Select PHP Version.
  3. Click Switch To PHP Options
  4. Set log_errors to Off
  5. Click Save

.htaccess

  1. Edit .htaccess in your public_html folder
  2. Enter the following code:1php_flag log_errors off
  3. Save the file.

php.ini

  1. Create a new file named php.ini in your public_html folder.
  2. Enter the following code:1log_errors = off
  3. Save the file.

Verify your changes

Create a phpinfo php page to check your settings are active.

Delete existing PHP error_log files

  1. View your webspace using FTP or cPanel File Manager
  2. Select your error_log file
  3. Delete

How to convert MBps to IOPS or calculate IOPS from MB/s

Most SSDs have two speed ratings for reading as well as for writing.  The first rating is the sustained MB/s performance, which is the main marketing most manufacturers use.  The second rating is the 4K Random IOPS performance, which gives a much better idea of how the drive will perform in the real world.  The sustained MB/s rating is the sequential transfer rate the SSD will maintain continuously, such as over a period of 30 seconds.  The 4K Random IOPS on the other hand is how many 4K (4096 byte) operations the drive will handle per second with each block being read or written to a random position.

Usually when a Random 4K IOPS figure is given, it may state that this is at a certain queue depth, such as 4, 16, 32 or 64.  With a queue depth of 4, this means that there are 4 separate threads taking place with the drive, each thread independently running its own transfers.  With the use of Native Command Queuing (NCQ), the SSD can handle these threads simultaneously to improve the overall throughput compared to running a single thread.  While many hard disks use native command queuing to line up read/write operations to minimise seek times between each read/write operation, SSDs can read from and write to multiple NAND cells simultaneously, where as the read/write head in a hard disk can only be in one physical place at any time.
While it is nice to see how many IOPS a drive is capable of, it is also useful to see how this translates into actual throughput or even vice versa.  For example, most benchmark tools such as CrystalDiskMark and AS SSD report the random 4K performance in throughput, i.e. MB/s, while the SSD’s specifications usually rates the 4K performance in IOPS.To see how to translate MBps into IOPS and vice versa, we need to do a little math:

IOPS = (MBps Throughput / KB per IO) * 1024
Or
MBps = (IOPS * KB per IO) / 1024

So let’s say we have an SSD claiming a Random 4K write speed of 20,000 IOPS and it achieves 76.2MB/s in the CrystalDiskMark with the QD32 write test.

To convert the 76.2MB/s to IOPS, we perform the following calculation:

IOPS = (76.2 / 4) * 1024
IOPS = 19.1 * 1024
IOPS = 19,558.4

To see what throughput we need to achieve to match the actual 20,000 IOPS claim, we can perform this calculation in reverse:

MBps = (20,000 * 4) / 1024
MBps = 80,000 / 1024
MBps = 78.125MB/s

Note that each manufacturer uses its own method of coming up with their SSD IOPS ratings.  Besides separate IOPS ratings for read and write speeds, a given SSD can behave quite different depending on the type of data being read or written, as well as the duration this transfer takes place.  For example, an SSD that achieves 5,000 Random 4K IOPS sustained write over a period of 30 seconds may only achieve 1,000 IOPS sustained write over a period of 5 minutes.  For SSDs using the SandForce processor, the compressibility of the data also has an impact, so two benchmark tools may show completely different IOPS readings if one tool sends uncompressible data and the other tool sends highly compressible data and also if one runs the benchmark for longer duration than the other.

🙂

Happy calculating.  

linux command to prevent dos attack by using netstat and iptables

Best you can do , IMO, is to set limits

sudo iptables -A INPUT -m limit --limit 50/minute --limit-burst 200 -j ACCEPT
sudo iptables -A INPUT -j REJECT

For port 80, use

sudo iptables -A INPUT -p tcp --dport 80 -m state --state NEW -m limit --limit 50/minute --limit-burst 200 -j ACCEPT
sudo iptables -A INPUT -m state --state RELATED,ESTABLISHED -m limit --limit 50/second --limit-burst 50 -j ACCEPT
sudo iptables -A INPUT -j REJECT

Problem with phpMyAdmin and PHP 7.2: “Warning in ./libraries/sql.lib.php#613 count(): Parameter must be an array or an object that implements Countable”

It’s possible that when you installed phpMyAdmin, the version in the repository (phpMyAdmin v4.6.6) was not fully compatible with PHP 7.2. There is a newer version available on the official website (v4.8 as of writing), which fixes these compatibility issues with PHP 7.2.

sql.lib.php

This error is caused by a line of code in /usr/share/phpmyadmin/libraries/sql.lib.php.

If you don’t want to wait for the repositories to update with the latest version, it is strongly recommended that you manually upgrade to the latest version of phpMyAdmin yourself.

Alternatively, you can make a change to sql.lib.php to temporarily fix the error.

Firstly, backup sql.lib.php before editing.

Firstly, backup sql.lib.php before editing.

sudo cp /usr/share/phpmyadmin/libraries/sql.lib.php /usr/share/phpmyadmin/libraries/sql.lib.php.bak

Edit sql.lib.php in nano.

sudo nano /usr/share/phpmyadmin/libraries/sql.lib.php

Press CTRL + W and search for (count($analyzed_sql_results['select_expr'] == 1)

Replace it with ((count($analyzed_sql_results['select_expr']) == 1)

Save file and exit. (Press CTRL + X, press Y and then press ENTER)

Import/Export issues

If you are also getting an error Warning in ./libraries/plugin_interface.lib.php#551 under import and export tabs:

Backup plugin_interface.lib.php

sudo cp /usr/share/phpmyadmin/libraries/plugin_interface.lib.php /usr/share/phpmyadmin/libraries/plugin_interface.lib.php.bak

Edit plugin_interface.lib.php

sudo nano /usr/share/phpmyadmin/libraries/plugin_interface.lib.php

Press CTRL + W and search for if (! is_null($options) && count($options) > 0) {

If not found, try search for if ($options != null && count($options) > 0)

Replace with if (! is_null($options) && count((array)$options) > 0) {

Save file and exit. (Press CTRL + X, press Y and then press ENTER)

Testing your email with Telnet

These FAQs will teach you how to test your IMAP, POP3 and SMTP settings using Telnet

Simply click on a title below to skip to the most appropriate FAQ. You can also click the Top button to return and make another selection.

  1. How can I use Telnet to test my IMAP e-mail account is working?
  2. How can I use Telnet to test my POP3 e-mail account is working?
  3. How can I use Telnet to test that my email account can send mail via SMTP?

How can I use Telnet to test my IMAP e-mail account is working?

This article explains how to use the telnet command in your command prompt console to establish whether your e-mail account is accepting connections.

In circumstances where your usual e-mail client software is not connecting to your IMAP mailbox, using telnet helps you to perform a basic assessment of whether your mailbox is functional. This can help you to eliminate your local software as an issue in being unable to receive your mail.

Please be aware that for Windows Vista & Windows 7, the telnet function is by default disabled and therefore it must be turned on from the Windows Features menu within the control panel.

  • Step 1 of 2Open up your command console – in most versions of Windows, click Start, then Run, type cmd and hit Enter.
  • Step 2 of 2Enter only the text in bold as shown in the example command box below, hitting Enter at the end of each line.
telnet imap.123-reg.co.uk 143
* OK [CAPABILITY IMAP4rev1 SASL-IR SORT THREAD=REFERENCES MULTIAPPEND UNSELECT
LITERAL+ IDLE CHILDREN NAMESPACE LOGIN-REFERRALS UIDPLUS LIST-EXTENDED I18NLEVEL=
1 AUTH=PLAIN] ATLAS/WebFusion Mail Server
01 LOGIN username@domain.com password
01 OK [CAPABILITY IMAP4rev1 SASL-IR SORT THREAD=REFERENCES MULTIAPPEND UNSELECT
LITERAL+ IDLE CHILDREN NAMESPACE LOGIN-REFERRALS UIDPLUS LIST-EXTENDED I18NLEVEL
=1 AUTH=PLAIN] Logged in.

This test will indicate whether or not you are able to connect successfully to your e-mail account. If you are able to connect successfully using Telnet, but not through your regular e-mail client, this suggests the issue may be caused by your local software and you should re-check account settings in your e-mail client in accordance with the vendors help documentation and our e-mail support pages.

If you would like to view all folders within a mailbox you can use the below command when connected via Telnet to the IMAP server.

. list "" "*"

Please note: In the code example above, generic values have been used for the mailbox usernames and passwords.

When testing your e-mail account connection using telnet, please ensure you have the correct e-mail account username and e-mail account password to hand.

How can I use Telnet to test my POP3 e-mail account is working?

This article explains how to use the telnet command in your command prompt console to establish whether your e-mail account is accepting connections.

In circumstances where your usual e-mail client software is not connecting to your POP3 mailbox, using telnet helps you to perform a basic assessment of whether your mailbox is functional. This can help you to eliminate your local software as an issue in being unable to receive your mail.

Please be aware that for Windows Vista & Windows 7, the telnet function is by default disabled and therefore it must be turned on from the Windows Features menu within the control panel.

  • Step 1 of 2Open up your command console – in most versions of Windows, click Start, then Run, type cmd and hit Enter.
  • Step 2 of 2Enter the text as shown in the example command box below, hitting Enter at the end of each line. For each successful command you issue, the server will return the message ‘+OK‘ indicating you should proceed to the next command.
telnet pop.123-reg.co.uk 110
+OK Hello there.
user your-emailmailboxusername
+OK Password required.
pass youremailpassword
+OK logged in.

This test will indicate whether or not you are able to connect successfully to your e-mail account. If you are able to connect successfully using telnet, but not through your regular e-mail client, this suggests the issue may be caused by your local software and you should re-check account settings in your e-mail client in accordance with the vendors help documentation and our e-mail support pages.

Please note: In the code example above, generic values have been used for the mailbox usernames and passwords.

When testing your e-mail account connection using telnet, please ensure you have the correct e-mail account username and e-mail account password to hand.

How can I use Telnet to test that my email account can send mail via SMTP?

This article explains how to use the telnet command in your command prompt console to establish whether your e-mail account can send emails via the the 123 Reg SMTP server.

In circumstances where your usual e-mail client software is not connecting to the 123 Reg SMTP server to send emails, using telnet helps you to perform a basic assessment of whether your email account is functional. This can help you to eliminate your local software as an issue in being unable to send your mail.

Please be aware that for Windows Vista & Windows 7, the telnet function is by default disabled and therefore it must be turned on from the Windows Features menu within the control panel.

  • Step 1 of 2Open up your command console – in most versions of Windows, click Start, then Run, type cmd and hit Enter.
  • Step 2 of 2Enter the text as shown in Bold in the example command box below, hitting Enter at the end of each line. For each successful command you issue, the server a return the message.
telnet smtp.123-reg.co.uk 25
220 mail6.atlas.pipex.net ESMTP Exim 4.71 - "ATLAS SMTP Service" Wed, 13 Jul 201
1 10:47:06 +0100
EHLO smtp.123-reg.co.uk
250-mail6.atlas.pipex.net Hello hns01-fw.internal.gxn.net [195.224.160.13]
250-SIZE 31457280
250-PIPELINING
250-AUTH PLAIN LOGIN
250 HELP
AUTH LOGIN
334 DXNl4gddhbWU3
cwtui3lAcmlja2ljaeFoYewuY2 (Base 64 encoded username)
334 UGFzc3dvcmQ6
YeGjc3ducmE (Base 64 encoded password)
235 Authentication succeeded
MAIL FROM: emailaddress@domain.com
250 OK
RCPT TO: recipent@theirdomain.com
250 Accepted
DATA
354 Enter message, ending with "." on a line by itself
Subject Test using Telnet
.
250 OK id=4Qgw3m-023484q-I5

This test will indicate whether or not you are able to connect successfully to send email from your e-mail account and if you see the statement OK it means the that the email message was sent to the recipient.

what possible reason to hack an app android

*decompiled using automated tools
To avoid such issues, organisations do some obfuscation (hiding) of code using free tools like ProGuard or other commercial tools. This makes decompilation a tough job.
However, a good hacker can even bypass restrictions set up by ProGuard. For this reason large organisations like Google and Facebook use commercial obfuscation tools to keep their code safe.

*Some apps can be easily hacked while some apps are very strictly coded.however there is always a posibility of hacking of the apps .you can easily hack some apps if your mobile is rooted

here are some apps that can easily hack any app

1.lucky patcher

2. hack app data

and if you want to hack something that is locked.then you can hack them by “force stop”ing the app from application settings.with this every lock will be disabled.

If you want to hack paid apps and get them for free then you can just google the app name like this

“Utorrent pro apk “

“asphalt cracked apk”

Complete Web Server Setup(Apache2, php, mysql, phpmyadmin)

$ sudo apt-get update
$ sudo apt-get install apache2
$ sudo ufw app list
$ sudo ufw allow 'Apache Full'
$ sudo ufw status
$ sudo systemctl status apache2
$ hostname -I
$ sudo apt-get install curl

Manage the Apache Process

$ sudo systemctl stop apache2
$ sudo systemctl start apache2
$ sudo systemctl restart apache2
$ sudo systemctl reload apache2
$ sudo systemctl disable apache2
$ sudo systemctl enable apache2

How to install PHP

$ apt-get update
$ apt-get upgrade
$ apt-get install php
$ php -v
$ apt-get install php-pear php-fpm php-dev php-zip php-curl php-xmlrpc php-gd php-mysql php-mbstring php-xml libapache2-mod-php
$ apt-cache search --names-only ^php
$ systemctl restart apache2

How To Install MySQL 

$ sudo apt update
$ sudo apt install mysql-server
$ sudo mysql_secure_installation
$ sudo mysql -u root -p
$ sudo systemctl status mysql.service

How To Install and Secure phpMyAdmin 

$ sudo apt update
$ sudo apt install phpmyadmin php-mbstring php-gettext
ON UBUNTU 20
$ sudo apt install phpmyadmin php-mbstring php-zip php-gd php-json php-curl

If Error

mysql> UNINSTALL COMPONENT "file://component_validate_password";

After phpmyadmin installation

mysql> INSTALL COMPONENT "file://component_validate_password";
$ sudo phpenmod mbstring
$ sudo systemctl restart apache2

Grant Permissions in MySQL

mysql> GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';
mysql> FLUSH PRIVILEGES;

Enabling mod_rewrite

$ sudo nano /etc/apache2/apache2.conf
$ sudo nano /etc/apache2/sites-available/000-default.conf


<Directory /home/ubuntu/public_html/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>


$ sudo a2enmod rewrite
$ sudo systemctl restart apache2

Install and Secure Redis on Ubuntu 18.04

$ sudo apt update
$ sudo apt install redis-server
$ sudo nano /etc/redis/redis.conf
$ sudo systemctl restart redis.service

Testing Redis

$ sudo systemctl status redis
Note: This setting is desirable for many common use cases of Redis. If, however, you prefer to start up Redis manually every time your server boots, you can configure this with the following command:

$ sudo systemctl disable redis
$ redis-cli
127.0.0.1:6379> ping
127.0.0.1:6379> set test "It's working!"
127.0.0.1:6379> get test
127.0.0.1:6379> exit
$ sudo systemctl restart redis

enable/disable site in ubuntu

a2ensite, a2dissite - enable or disable an apache2 site / virtual host

DESCRIPTION

This manual page documents briefly the a2ensite and a2dissite commands.

       a2ensite  is  a  script  that  enables  the specified site (which contains a <VirtualHost>
       block) within the apache2  configuration.   It  does  this  by  creating  symlinks  within
       /etc/apache2/sites-enabled.   Likewise,  a2dissite  disables  a  site  by  removing  those
       symlinks.  It is not an error to enable a site which is already enabled, or to disable one
       which is already disabled.

       Apache  treats the very first virtual host enabled specially as every request not matching
       any actual directive is being redirected there. Thus it should be  called  000-default  in
       order to sort before the remaining hosts to be loaded first.

OPTIONS

 -q, --quiet
              Don't show informative messages.

       -m, --maintmode
              Enables  the  maintainer  mode,  that  is  the  program  invocation  is effectuated
              automatically by a maintainer script. This switch should not be used by end users.

       -p, --purge
              When disabling a module, purge all traces of the module in the internal state  data
              base.

EXIT STATUS

       a2ensite  and  a2dissite  exit with status 0 if all sites are processed successfully, 1 if
       errors occur, 2 if an invalid option was used.

EXAMPLES

              a2dissite 000-default

       Disables the default site.

FOR Enable SSL Module 

 sudo a2enmod ssl
 sudo a2ensite default-ssl 

FILES

       /etc/apache2/sites-available
              Directory with files giving information on available sites.

       /etc/apache2/sites-enabled
              Directory with links to the files in sites-available for enabled sites.

header set not working in ubuntu

$ sudo a2enmod headers
$ sudo service apache2 reload

after that write bellow config in your .htaccess file


 Header set X-XSS-Protection "1; mode=block"
  Header set X-Content-Type-Options nosniff

oops in php interview questions

1) What is OOPS?

OOPS is abbreviated as Object Oriented Programming system in which programs are considered as a collection of objects. Each object is nothing but an instance of a class.

2) Write basic concepts of OOPS?

Following are the concepts of OOPS:

  1. Abstraction
  2. Encapsulation
  3. Inheritance
  4. Polymorphism

3) What is a class?

A class is simply a representation of a type of object. It is the blueprint/plan/template that describes the details of an object.

4) What is an Object?

An object is an instance of a class. It has its own state, behavior, and identity.

5) What is Encapsulation?

Encapsulation is an attribute of an object, and it contains all data which is hidden. That hidden data can be restricted to the members of that class.

Levels are Public, Protected, Private, Internal, and Protected Internal.

6) What is Polymorphism?

Polymorphism is nothing but assigning behavior or value in a subclass to something that was already declared in the main class. Simply, polymorphism takes more than one form.

7) What is Inheritance?

Inheritance is a concept where one class shares the structure and behavior defined in another class. If Inheritance applied to one class is called Single Inheritance, and if it depends on multiple classes, then it is called multiple Inheritance.

8) What are manipulators?

Manipulators are the functions which can be used in conjunction with the insertion (<<) and extraction (>>) operators on an object. Examples are endl and setw.

9) Explain the term constructor

A constructor is a method used to initialize the state of an object, and it gets invoked at the time of object creation. Rules for constructor are:

  • Constructor Name should be the same as a class name.
  • A constructor must have no return type.

10) Define Destructor?

A destructor is a method which is automatically called when the object is made of scope or destroyed. Destructor name is also same as class name but with the tilde symbol before the name.

11) What is an Inline function?

An inline function is a technique used by the compilers and instructs to insert complete body of the function wherever that function is used in the program source code.

12) What is a virtual function?

A virtual function is a member function of a class, and its functionality can be overridden in its derived class. This function can be implemented by using a keyword called virtual, and it can be given during function declaration.

A virtual function can be declared using a token(virtual) in C++. It can be achieved in C/Python Language by using function pointers or pointers to function.

13) What is a friend function?

A friend function is a friend of a class that is allowed to access to Public, private, or protected data in that same class. If the function is defined outside the class cannot access such information.

A friend can be declared anywhere in the class declaration, and it cannot be affected by access control keywords like private, public, or protected.

14) What is function overloading?

Function overloading is a regular function, but it can perform different tasks. It allows the creation of several methods with the same name which differ from each other by the type of input and output of the function.

Example


void add(int& a, int& b);
 
void add(double& a, double& b);
 
void add(struct bob& a, struct bob& b);

15) What is operator overloading?

Operator overloading is a function where different operators are applied and depends on the arguments. Operator,-,* can be used to pass through the function, and it has its own precedence to execute

16) What is an abstract class?

An abstract class is a class which cannot be instantiated. Creation of an object is not possible with an abstract class, but it can be inherited. An abstract class can contain only an Abstract method. Java allows only abstract method in abstract class while other languages allow non-abstract method as well.

17) What is a ternary operator?

The ternary operator is said to be an operator which takes three arguments. Arguments and results are of different data types, and it depends on the function. The ternary operator is also called a conditional operator.

18) What is the use of finalize method?

Finalize method helps to perform cleanup operations on the resources which are not currently used. Finalize method is protected, and it is accessible only through this class or by a derived class.

19) What are the different types of arguments?

A parameter is a variable used during the declaration of the function or subroutine, and arguments are passed to the function body, and it should match with the parameter defined. There are two types of Arguments.

  • Call by Value – Value passed will get modified only inside the function, and it returns the same value whatever it is passed into the function.
  • Call by Reference – Value passed will get modified in both inside and outside the functions and it returns the same or different value.

20) What is the super keyword?

The super keyword is used to invoke the overridden method, which overrides one of its superclass methods. This keyword allows to access overridden methods and also to access hidden members of the superclass.

It also forwards a call from a constructor, to a constructor in the superclass.

21) What is method overriding?

Method overriding is a feature that allows a subclass to provide the implementation of a method that overrides in the main class. It will override the implementation in the superclass by providing the same method name, same parameter, and same return type.

22) What is an interface?

An interface is a collection of an abstract method. If the class implements an interface, it thereby inherits all the abstract methods of an interface.

Java uses Interface to implement multiple inheritances.

23) What is exception handling?

An exception is an event that occurs during the execution of a program. Exceptions can be of any type – Runtime exception, Error exceptions. Those exceptions are adequately handled through exception handling mechanism like try, catch, and throw keywords.

24) What are tokens?

A compiler recognizes a token, and it cannot be broken down into component elements. Keywords, identifiers, constants, string literals, and operators are examples of tokens.

Even punctuation characters are also considered as tokens. Example: Brackets, Commas, Braces, and Parentheses.

25) What is the main difference between overloading and overriding?

Overloading is static Binding, whereas Overriding is dynamic Binding. Overloading is nothing but the same method with different arguments, and it may or may not return the equal value in the same class itself.

Overriding is the same method names with the same arguments and return types associated with the class and its child class.

26) What is the main difference between a class and an object?

An object is an instance of a class. Objects hold multiple information, but classes don’t have any information. Definition of properties and functions can be done in class and can be used by the object.

A class can have sub-classes, while an object doesn’t have sub-objects.

27) What is an abstraction?

Abstraction is a useful feature of OOPS, and it shows only the necessary details to the client of an object. Meaning, it shows only required details for an object, not the inner constructors, of an object. Example – When you want to switch on the television, it is not necessary to know the inner circuitry/mechanism needed to switch on the TV. Whatever is required to switch on TV will be shown by using an abstract class.

28) What are the access modifiers?

Access modifiers determine the scope of the method or variables that can be accessed from other various objects or classes. There are five types of access modifiers, and they are as follows:

  • Private
  • Protected
  • Public
  • Friend
  • Protected Friend

29) What are sealed modifiers?

Sealed modifiers are the access modifiers where the methods can not inherit it. Sealed modifiers can also be applied to properties, events, and methods. This modifier cannot be used to static members.

30) How can we call the base method without creating an instance?

Yes, it is possible to call the base method without creating an instance. And that method should be “Static method.”

Doing Inheritance from that class.-Use Base Keyword from a derived class.

31) What is the difference between new and override?

The new modifier instructs the compiler to use the new implementation instead of the base class function. Whereas, Override modifier helps to override the base class function.

32) What are the various types of constructors?

There are three types of constructors:

–  Default Constructor – With no parameters.

–  Parametric Constructor – With Parameters. Create a new instance of a class and also passing arguments simultaneously.

–  Copy Constructor – Which creates a new object as a copy of an existing object.

33) What is early and late Binding?

Early binding refers to the assignment of values to variables during design time, whereas late Binding refers to the assignment of values to variables during run time.

34) What is ‘this’ pointer?

THIS pointer refers to the current object of a class. THIS keyword is used as a pointer which differentiates between the current object with the global object. It refers to the current object.

35) What is the difference between structure and a class?

The default access type of a Structure is public, but class access type is private. A structure is used for grouping data, whereas a class can be used for grouping data and methods. Structures are exclusively used for data, and it doesn’t require strict validation, but classes are used to encapsulate and inherent data, which requires strict validation.

36) What is the default access modifier in a class?

The default access modifier of a class is Private by default.

37) What is a pure virtual function?

A pure virtual function is a function which can be overridden in the derived class but cannot be defined. A virtual function can be declared as Pure by using the operator =0.

Example –

Virtual void function1() // Virtual, Not pure
Virtual void function2() = 0 //Pure virtual

38) What are all the operators that cannot be overloaded?

Following are the operators that cannot be overloaded -.

  1. Scope Resolution (::)
  2. Member Selection (.)
  3. Member selection through a pointer to function (.*)

39) What is dynamic or run time polymorphism?

Dynamic or Run time polymorphism is also known as method overriding in which call to an overridden function is resolved during run time, not at the compile time. It means having two or more methods with the same name, same signature but with different implementation.

40) Do we require a parameter for constructors?

No, we do not require a parameter for constructors.

41) What is a copy constructor?

This is a special constructor for creating a new object as a copy of an existing object. There will always be only one copy constructor that can be either defined by the user or the system.

42) What does the keyword virtual represented in the method definition?

It means we can override the method.

43) Whether static method can use nonstatic members?

False.

44) What are a base class, subclass, and superclass?

The base class is the most generalized class, and it is said to be a root class.

A Subclass is a class that inherits from one or more base classes.

The superclass is the parent class from which another class inherits.

45) What is static and dynamic Binding?

Binding is nothing but the association of a name with the class. Static Binding is a binding in which name can be associated with the class during compilation time, and it is also called as early Binding.

Dynamic Binding is a binding in which name can be associated with the class during execution time, and it is also called as Late Binding.

46) How many instances can be created for an abstract class?

Zero instances will be created for an abstract class. In other words, you cannot create an instance of an Abstract Class.

47) Which keyword can be used for overloading?

Operator keyword is used for overloading.

48) What is the default access specifier in a class definition?

Private access specifier is used in a class definition.

49) Which OOPS concept is used as a reuse mechanism?

Inheritance is the OOPS concept that can be used as a reuse mechanism.

50) Which OOPS concept exposes only the necessary information to the calling functions?

Encapsulation