A Day in Noida: Learning Begins

Today was my first day in Apex Pvt Ltd and I have learnt the basic elements of Java. These elements are given below:

1. What are the uses of println() and printf?
Ans: println() prints a new blank line and then your message. 
printf() provides string formatting similar to the printf function in C. printf() is primarily needed when you need to print big strings to avoid string concatenation in println() which can be confusing at times (Although both can be used in almost all cases).
Eg.

int a = 10;int b = 20; 
println("a: " + a + " b: " + b);      //Tedious String Concatenation
printf("a: %d b: %d\n", a, b);     // Output using string formatting. 
While printf() enables you to print fractional outputs up to any decimal place in a single line, the same task using println() can get very complex.

2. What is the use of Java?
Ans: Java is a programming language that developers use to create applications on your computer. Chances are you've downloaded a program that required the Java runtime, and so you probably have it installed it on your system. Java also has a web plug-in that allows you to run these apps in your browser.

Java is not, however, the same as JavaScript. In fact, they don't have a ton of similarities besides their names. JavaScript is generally used within HTML documents (like web pages) rather than as standalone "apps" that run inside them. This can be a bit confusing since Java also runs in your browser, but they are quite different. A large number of websites use JavaScript; very few require Java.
3. Interpret the line "system.out.print()".
Ans: System is a class, that has a public static field out. So it's more like
class System
{
public static PrintStream out;
}
class PrintStream
{ public void println ...}
This is a slight oversimplification, as the PrintStream class is actually in the java.io package, but it's good enough to show the relationship of stuff.

That's all for the day.

Comments

Post a Comment

Thank you!

Popular posts from this blog

How to add Internet download manager extension in the Chrome browser

Python Deciding factor