Declare Main Method as Non-Static in Java

Maruthi Krishna
Updated on 29-Jun-2020 12:59:51

7K+ Views

The public static void main(String ar[]) method is the entry point of the execution in Java. When we run a .class file JVM searches for the main method and executes the contents of it line by line.You can write the main method in your program without the static modifier, the program gets compiled without compilation errors. But, at the time of execution JVM does not consider this new method (without static) as the entry point of the program.  It searches for the main method which is public, static, with return type void, and a String array as an argument.public static int main(String[] ... Read More

Declare Final Variables Without Initialization in Java

Maruthi Krishna
Updated on 29-Jun-2020 12:57:54

5K+ Views

In Java, final is the access modifier which can be used with a filed class and a method.When a method if final it cannot be overridden.When a variable is final its value cannot be modified further.When a class is final it cannot be extended.Declaring final variable without initializationIf you declare a final variable later on you cannot modify or, assign values to it. Moreover, like instance variables, final variables will not be initialized with default values.Therefore, it is mandatory to initialize final variables once you declare them.Still, if you try to declare final variables without initialization that will generate a ... Read More

Working of the 8257 DMA Controller

Vrundesha Joshi
Updated on 29-Jun-2020 12:56:38

2K+ Views

Initially the processor programs 8257. Here the processor behaves as the master and 8257 here works in the slave mode. The channel of the program is obtained by writing to the Address Register from the starting address of memory for transferring Data, and writing to the Counter Register where the number of bytes to be transferred is by using the Direct Memory Access Scheme. The number of bytes of information which is specified by the Least Significant 14 bits. Whereas The Most Significant 2 bits indicate what type of data transfer is to occur. After that the processor writes to ... Read More

Ways to Initialize a Final Variable in Java

Maruthi Krishna
Updated on 29-Jun-2020 12:56:07

3K+ Views

In Java, final is the access modifier which can be used with a filed, class and a method.When a method if final it cannot be overridden.When a variable is final its value cannot be modified further.When a class is final it cannot be extended.Initializing a final variableOnce you declare a final variable, it is a must to initialize it. You can initialize the final instance variable −At the time of declaration as.public final String name = "Raju"; public final int age = 20;Within an instance (non-static) block.{    this.name = "Raju";    this.age = 20; }Within a default constructor.public final ... Read More

Why Final Variable Doesn't Require Initialization in Main Method in Java

Maruthi Krishna
Updated on 29-Jun-2020 12:53:35

771 Views

In Java final is the access modifier which can be used with a filed class and a method.When a method if final it cannot be overridden.When a variable is final its value cannot be modified further.When a class is final it cannot be extended.Declaring final variable without initializationIf you declare a variable as final, it is mandatory to initialize it before the end of the constructor. If you don’t, a compile-time error is generated.Example Live Demopublic class Student {    public final String name;    public final int age;    public void display(){       System.out.println("Name of the Student: "+this.name); ... Read More

Can We Declare Constructor as Final in Java

Maruthi Krishna
Updated on 29-Jun-2020 12:51:54

4K+ Views

A constructor is used to initialize an object when it is created. It is syntactically similar to a method. The difference is that the constructors have the same name as their class and, have no return type.There is no need to invoke constructors explicitly these are automatically invoked at the time of instantiation.Example Live Demopublic class Example {    public Example(){       System.out.println("This is the constructor of the class example");    }    public static void main(String args[]) {       Example obj = new Example();    } }OutputThis is the constructor of the class exampleFinal methodWhenever you ... Read More

Use of ini_set in PHP

Alok Prasad
Updated on 29-Jun-2020 12:50:11

6K+ Views

PHP allows the user to modify some of its settings mentioned in php.ini using ini_set(). This function requires two string arguments. The first one is the name of the setting to be modified and the second one is the new value to be assigned to it.Parametersvar nameNot all the available options can be changed using ini_set(). There is a list of all available options in the appendix.new valueThe new value for the option.ExampleGiven the line of code will enable the display_error setting for the script if it’s disabled. We need to put the above statement, at the top of the ... Read More

Is PHP Compiled or Interpreted?

Alok Prasad
Updated on 29-Jun-2020 12:49:09

3K+ Views

Basically, PHP is interpreted but PHP is compiled down to an intermediate bytecode that is then interpreted by the runtime Zend engine.PHP compiler is responsible forconvert the code to a bytecode that can be used by the runtime engine.resolve functions, names and classes namescreating a symbol tablePHP Interpreter doesGoes through the bytecode line by line and executes itHandles runtime exception

Differentiate Between Exception and Error in PHP

Alok Prasad
Updated on 29-Jun-2020 12:48:40

2K+ Views

Let's discuss the differences between errors and exceptions.Recovering from Error is not possible. The only solution to errors is to terminate the execution. Whereas we can recover from Exception by using either try-catch blocks or throwing an exception back to the caller.You will not be able to handle the Errors using try-catch blocks. Even if you handle them using try-catch blocks, your application will not recover if they happen. On the other hand, Exceptions can be handled using try-catch blocks and can make program flow normally if they happen.Exceptions are related to the application whereas Errors are related to the ... Read More

Can Redeclaring a Variable Destroy Its Value in JavaScript

vineeth.mariserla
Updated on 29-Jun-2020 12:47:46

343 Views

Re-declaring a variable will not destroy the value of a variable, until and unless it is assigned with some other new value.If we look at the following example variables "x" and ''y'' were assigned with values 4 and 8 respectively, later on when those variables were reassigned, the old values were replaced with the new values and displayed as shown in the output.ExampleLive Demo           var x = new Number(4);       var x = 7;       var y = 8;       var y = 10;       document.write(x);     ... Read More

Advertisements