Showing posts with label Language Fundamental. Show all posts
Showing posts with label Language Fundamental. Show all posts

Java - Command Line Arguments / Chapter - 8 /Language Fundamental


javabychetan.blogspot.com

java command line arguments 


1.The arguments which are passing from command-prompt are called command-line arguments.
With these command-line arguments, JVM will create an array & by passing that array as arguments
JVM will call main( ) method.
for  example:-
class Test
{
      public static void main(String [ ] args)

     {


       System.out.println("javabychetan.blogspot.com ");

       for(int i=0;i<args.length;i++)

           {

           System.out.println(args[i]);

           }

       }

}

Java- What is the main( ) method in JAVA / Chapter - 7 /Language Fundamental


java main

java main method


You must be thinking that a particular line which always there in every java program is:-                            
public static void main(String [ ] args)

Q.what is this ???
A.The answer is this the main( ) method of java. The starting point from where the JVM starts reading &
     executing the java program.

  1. Whether a class contains main( ) method or not and whether main( ) method declared according to requirements or not these things won't checked by Compiler.

Java-Types of Variables / Chapter - 5 /Language Fundamental



Java Types Of Variables


Based on the position of declaration & behavior all variables are divided into three parts.


1.instance variable


2.static variable


3.local variable




 


1.instance variable:-



  • If the value of a variable varied from object to object is called Instance variable.

  • For every object, a separate copy of instance variable will be created.

  • Instance variable should be declared within the class directly, but outside of any method/block/constructor.

Java- Arrays / Chapter - 4 / Language Fundamental


array java

Array:-


An array is an index collection of fixed number of homogeneous data elements.

The main advantage of an array is we can represent a huge number of elements by a single variable.

But the main disadvantage of an array is it is fixed in size so that once the array is created then there is no chance of increasing the size of the array based on our requirement.

Hence to use an array, we should know the size in advance.

Array Declaration;-


How to declare an array?

Let's see in how many ways we can declare an array.


1-D Array Declaration:-


int [ ]    x;       (Recommended to use)


int    [ ]x;


int      x[ ];


 Above all three declaration of the 1-D array is valid.If we are using other than this then we will get compile time error.


 


2-D Array Declaration:-


 int [ ][ ]     x;


 int          [ ][ ]x;


 int         x[ ][ ];


 int  [ ]   x [ ];


int [ ]        [ ]x;


int       [ ]x [ ];


Above all declaration of 2-D array is valid.If we are using other than this than we will get compile time error.

 

3-D Array Declaration:-

Java- Data types / Chapter - 3 /Language Fundamental


javabychetan.blogspot.com


Data Types:-



In Java, every variable and every expression have some type.
Each and every data type is clearly defined.

Every assignment should check by the compiler for Type compatibility.

Now because of above reasons, we can conclude that java is strongly typed language.

Now let's see what are the data type available in java.





1. byte
size = 1 byte(8 bits)
MAX_VALUE = 127
MIN_VALUE = -128
Range = -128 to 127





 

Java- Identifiers /Chapter - 1 /Language Fundamental



Que: What is Identifier in JAVA?
Ans:  Any name in a java program is called identifier. It can be a class name, variable name, method name, label name.

example:-
Q. How many identifiers are in the following program?



 Ans is
(D)
Description:-

Test, String & System are class names means 3.
main()  & println()are methods means 2.
args is a reference variable of String[] means 1
Hence there are total 3+2+1= 6 identifiers..Rules For Defining Java Identifier

Rules For Defining Java Identifier




Rule 1.
a to z
A to Z
0 to 9
$ and _



example:-
total_number           (valid)

total#                      (invalid) 


If we are using other than this we will get compile time error.

Flipkart End Of Season Sale






© Copyright 2017 Javabychetan.blogspot.com