Angstroms Number int a = 1153; 1 ka cube , 5 ka cube and 3 ka cube. int a = 153; int c = 0; while(a > 0 ){ int b = a%10; b = b*b*b; c += b; a = a/10; } System.out.println(c);
function overloading happens two or more function with the same name with different parameters or arguments fun(34); fun("hello"); static void sum(int a){ System.out.println(a) } static void sum(String a){ System.out.println(a); } At compile time it's decide which function to take no of argument should be different or no of type should be different
public class HelloWorld{ public static void main(String []args){ System.out.println("Hello World"); int b = 200; sum(); } static void sum(){ int a = 100; System.out.println(a); } } function scoping jasa ya sum() wala method ka under hum b ko access nahi kar sakta because wo function scope ka bahar haa sum(){ } Block level scope { } public class HelloWorld{ public static void main(String []args){ System.out.println("Hello World") { int c = 100; } System.out.println(c); } } asa karana ga toa error aya ga because hum block ka bhar c ko print karwa...
every thing is class like file ka name .java sa save hota haa jo je ake class haa class Main{ } java par bhi Capital letter sa start ho vo Class ka under ata haa class ka matlab name,group of properties and function class are know as method Scanner jo haa onput lana ka lia System.in ka matlab haa keybord sa input lana ka lia Type Casting :-
public class HelloWorld{ public static void main(String []args){ sum(); } static void sum(){ System.out.println("hello world"); } } public class HelloWorld{ public static void main(String []args){ System.out.println("Hello World"); int a = sum(); System.out.println(a); } static int sum(){ return 20; } }