Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Aviance School is one of the largest web solutions platform in India for developers to learn and share their programming knowledge and build their careers.
Passing by reference means the called functions’ parameter will be the same as the callers’ passed argument (not the value, but the identity – the variable itself).
Pass by value means the called functions’ parameter will be a copy of the callers’ passed argument.
NEW – We can create a new Thread object using new operator and the newly created thread that has not yet started the execution.
RUNNABLE – Either the thread is running or ready for execution but it’s waiting for resource allocation.
BLOCKED – Waiting to acquire a monitor lock to enter or re-enter a synchronized block/method.
WAITING – Waiting for some other thread to perform a particular action without any time limit.
TIMED_WAITING – Waiting for some other thread to perform a specific action for a specified time period.
TERMINATED – The thread has completed its execution.
Java does not allow Default Arguments.
A daemon thread is a thread that does not prevent the JVM from exiting when the program finishes but the thread is still running. An example for a daemon thread is the garbage collection.
The basic Example:
public class DaemonThreadExp extends Thread {
public void run() {
System.out.println("Entering to the run method..");
try {
System.out.println("In the run Method: currentThread() is" + Thread.currentThread());
while (true) {
try {
Thread.sleep(1000);
} catch (InterruptedException x) {}
System.out.println("In the run method: woke up again");
}
} finally {
System.out.println("Leaving from the run Method");
}
}
public static void main(String[] args) {
System.out.println("Entering the main Method");
DaemonThreadExp t = new DaemonThreadExp();
t.setDaemon(true);
t.start();
try {
Thread.sleep(5000);
} catch (InterruptedException x) {}
System.out.println("Leaving from the main method");
}
}
>> operator to shift bits, the right most bit of a signed number is lost and a new bit is added on left most position.
>>> operator doesn’t preserve sign and always adds zero into left most position.
The Canvas control represents a blank rectangular area where the user can draw or trap input events from the user.
Canvas class inherits the Component class.
Constructor of the Canvas class:
Canvas()
Canvas(GraphicsConfiguration c)
Methods:
addNotify()
createBufferStrategy(int n)
createBufferStrategy(int n, BufferCapabilities c)
getBufferStrategy()
paint(Graphics g)
update(Graphics g)
Basic Example:
import java.awt.*;
public class MyCanvasExample
{
public MyCanvasExample()
{
Frame f= new Frame("My Canvas Example:");
f.add(new MyCanvas());
f.setLayout(null);
f.setSize(300, 300);
f.setVisible(true);
}
public static void main(String args[])
{
new MyCanvasExample();
}
}
class MyCanvas extends Canvas
{
public MyCanvas() {
setBackground (Color.BLACK);
setSize(250, 200);
}
public void paint(Graphics g)
{
g.setColor(Color.RED);
g.fillOval(60, 60, 120, 60);
}
}
The isAlive() method of thread class tests if the thread is alive. A thread is considered alive when the start() method of thread class has been called and the thread is not yet dead.
This method returns true if the thread is still running and not finished.
Basic Example:
public class CodeIsAlive extends Thread
{
public void run()
{
try
{
Thread.sleep(500);
System.out.println("Is run() method isAlive "+Thread.currentThread().isAlive());
}
catch (InterruptedException ie) {
}
}
public static void main(String[] args)
{
CodeIsAlive t1 = new CodeIsAlive();
System.out.println("Before starting thread isAlive: "+t1.isAlive());
t1.start();
System.out.println("After starting thread isAlive: "+t1.isAlive());
}
}
The suspend() method of thread class puts the thread from running to waiting state. This method is used if you want to stop the thread execution and start it again when a certain event occurs. This method allows a thread to temporarily cease or stop the execution.
Basic Example:
public class JavaSuspendExp extends Thread
{
public void run()
{
for(int i=1; i<10; i++)
{
try
{
// thread to sleep for 1000 milliseconds
sleep(1000);
System.out.println(Thread.currentThread().getName());
}catch(InterruptedException e){System.out.println(e);}
System.out.println(i);
}
}
public static void main(String args[])
{
// creating three threads
JavaSuspendExp t1=new JavaSuspendExp ();
JavaSuspendExp t2=new JavaSuspendExp ();
JavaSuspendExp t3=new JavaSuspendExp ();
// call run() method
t1.start();
t2.start();
// suspend t2 thread
t2.suspend();
// call run() method
t3.start();
}
}
GregorianCalendar is a subclass of a Calendar that implements the most widely used Gregorian Calendar with which we are familiar.
Basic Example:
import java.util.Calendar;
import java.util.GregorianCalendar;
class CalendarAVNC {
public static void main(String[] args)
{
// Here we create an object of Calendar Class
Calendar cal = Calendar.getInstance();
/* Creating an object of GregorianCalendar Class */
GregorianCalendar gcal = new GregorianCalendar();
/* Displaying Current Date using Calendar Class */
System.out.println("Calendar date is: "+ cal.getTime());
/* Displaying Current Date using
GregorianCalendar Class */
System.out.print("Gregorian date is: "+ gcal.getTime());
} // end of main function
} // end of class
A socket is one endpoint of a two-way communication link between two programs running on the network.
A socket is bound to a port number so that the TCP layer can identify the application that data is destined to be sent to.
Socket Types
There are four types of sockets available to the users.
The Classes
The Interfaces
Exceptions
Downcasting with java instance of operator. When we want to cast a Super class to Sub class, we use Downcasting and it is not directly possible in Java.
Cat c = new Cat();
Animal a = (Animal) c; //Explicitly you have done upcasting. Actually no need, we can directly type cast like Animal a = c; compiler now treat Cat as Animal but still it is Cat even after upcasting
c.callme();
a.callme(); // It calls Cat's method even though we use Animal reference.
((Cat) a).callme2(); // Downcasting: Compiler does know Animal it is, In order to use Cat methods, we have to do typecast explicitly.
// Internally if it is not a Cat object it throws ClassCastException
RSS means Really Simple Syndication. RSS is a type of web feed that allows users and applications to access updates to websites in a standardized, computer-readable format.
RSS feeds also benefit users who want to receive timely updates from favorite websites or to aggregate data from many websites. The RSS feed is always the latest published content for a website.
The guest post refers to a post that is published by some guests on the other website’s blog section.This is a great way to promote your website to your target audience. Guest posting plays an important role in off-page SEO as it allows to get backlinks from relevant sources which will drive traffic.
Blog commenting plays an important role in a website’s SEO. Blog comments help the blog to drive traffic on your blog and makes it social.
Blog Commenting in SEO and it’s needed?
1.Backlinks
This is the most important reasons to do blog commenting.
2.Gain Traffic and great way to grow your network
3. Build relations with your website users.
4.Brand Value
TLD (top-level domain) is the suffix or extension tied to a website. Most of the websites use the top-level domain com, commonly called “dot” com.Other common TLDs are net, org, and edu.
Types of TLDs are:
1. Generic Top-Level Domains (gTLD):
Some examples include “.edu” for educational sites and .”com” for commercial sites.
2. Country-Code Top-Level Domains (ccTLD):
Every ccTLD recognizes a specific country and it is generally two letters long. For example, the ccTLD for Australia is “.au” and for India is “.in”
3. Sponsored Top-Level Domains (sTLD):
The sTLD is supervised by private organization.
4. Infrastructure Top-Level Domains:
The Internet Assigned Numbers Authority controls this TLD
The Google AMP for SEO add-on allows to create mobile optimized content for the product details pages of your store.
AMP means Accelerated Mobile Pages, a Google project, which aims to build web pages that are light weight and fast to load, specially on mobile devices.
The different ways to visually hide content:
There are multiple ways of hiding an element in CSS. You can hide it by setting opacity to 0, visibility to hidden, display to none or by setting extreme values for absolute positioning.
Opacity:
.hide {
opacity: 0;
}
Visibility:
.hide {
visibility: hidden;
}
Display:
.hide {
display: none;
}
Position:
.hide {
position: absolute;
top: -9999px;
left: -9999px;
}
There are four types of @media properties.
all – for all media type devices
print – for printers
speech – for screenreaders that “reads” the page out loud
screen – for computer screens, tablets, smart-phones etc.
Here is an example of @media property other than screen:
@media print {
body {
color: red;
}
}
Advantages
Disadvantages