TutorMe homepage
Subjects
PRICING
COURSES
Start Free Trial
Krutarth N.
Development Engineer in Oracle
Tutor Satisfaction Guarantee
Java Programming
TutorMe
Question:

How to use static in java? what is the output of following program? class A { static int i; static { System.out.println(1); i = 100; } } public class StaticInitializationBlock { static { System.out.println(2); } public static void main(String[] args) { System.out.println(3); System.out.println(A.i); } }

Krutarth N.

Firstly before calling main the static block in class StaticInitializationBlock will execute and 2 will be printed. Then 3 will be printed by simple output command in the main function. Later the 'i' variable of class A will be called and its value will be printed. But its value is initialized in static block so it will execute first by first printing 1 and then printing the value of i i.e 100. Output: 2 3 1 100

Trigonometry
TutorMe
Question:

How to solve questions in Trogonometry?

Krutarth N.

Main problem in solving questions in trigonometry is visualization by different angles. It comes through practice when you can see multiple angles,sides and ratios and comapre them to find the required sides or ratios. Trigonometry concepts are vastly used in the field of finding the depth of ocean , height of buildings,etc

C++ Programming
TutorMe
Question:

What are pointers in C++? Most of the students gets difficulty in Pointers.

Krutarth N.

Pointers are nothing but special variable which stores the address of the the normal variable in C and C++ programming. You can access the value of the pointers by the unary operator *. For example: // C program to demonstrate use of * for pointers in C #include <stdio.h> int main() { // A normal integer variable int Var = 10; // A pointer variable that holds address of var. int *ptr = &Var; // This line prints value at address stored in ptr. //Value stored is value of variable "var" printf("Value of Var = %d\n", *ptr); // The output of this line may be different in different runs even on same machine. printf("Address of Var = %p\n", ptr); // We can also use ptr as lvalue (Left hand side of assignment) *ptr = 20; // Value at address is now 20 // This prints 20 printf("After doing *ptr = 20, *ptr is %d\n", *ptr); return 0; } Output : Value of Var = 10 Address of Var = 0x7fffa057dd4 After doing *ptr = 20, *ptr is 20

Send a message explaining your
needs and Krutarth will reply soon.
Contact Krutarth